Advertisement

Visual C++ help

Started by April 18, 2002 10:07 AM
0 comments, last by SpiderTiger 22 years, 8 months ago
hey, I have question. I''m playing around with windows programming and I input this code: #include <windows.h> #define WIN32_LEAN_AND_MEAN int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { MessageBox(NULL, "\tHello, world!", "My First Windows Application", 0); return 0; } When I compile, VC++ tells me that there are no errors. but when I try to execute, it comes up with: --------------------Configuration: main - Win32 Debug-------------------- Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/main.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. main.exe - 2 error(s), 0 warning(s) how can i get this to stop? I know the code is right... am I missing something in the configuration of VC++? Thanks for any help Chris
Side note: #define WIN32_LEAN_AND_MEAN is meaningless if it comes after you include windows.h, etc. Move it above the #include directive.

You created a default project (ie, you started typing then hit compile and it asked you whether it should create a default workspace and you said yes), which defines a Win32 Console Application and expects main as the application entry point. You want to close your workspace, hit File->New..., select the Project tab and make sure Win32 Application is the selected type. Type in a project name, hit OK and choose "empty workspace" in the dialog that follows. Then use the Project->Add Files... dialog to add your existing code and rebuild. Presto!

Now the chastisement. It is silly - stupid, even - to start using a complex piece of software without reading the manual! MSVC comes with the MSDN Library, which contains reference books on using Visual C++. Read them! Knowing how to write code isn't enough; you need to understand your development tools as well.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!

[edited by - Oluseyi on April 18, 2002 11:23:16 AM]

This topic is closed to new replies.

Advertisement