Can't compile this little program!!!

Hello,

I'm trying to compile this simple Hello World script using Visual Studio 2005 and can't even make it work. Here is my script:

#include <windows.h>

int CALLBACK WinMain(

HINSTANCE hInstance,

HINSTANCE hInstNULL,

LPSTR lpszCmdLine,

int nCmdShow)

{

MessageBox(NULL,"Hello World","Tutorial Example 1",MB_OK|MB_ICONINFORMATION);

return(0);

}

I get the following errors:

error LNK2028: unresolved token (0A000021) "extern "C" int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)" ( MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,char const *,char const *,unsigned int)" ( MessageBox@@$$J0YAHPAUHWND__@@PBD1I@Z)

1>PROG3_2.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)" ( MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,char const *,char const *,unsigned int)" ( MessageBox@@$$J0YAHPAUHWND__@@PBD1I@Z)

What option do I have to toggle or what part of my coding should I modify I am totally new to programming and would like to know more about it. Thanks!!



Answer this question

Can't compile this little program!!!

  • Uleepera

    Hi,
    you're not linking your program with the user32.lib (that's where the MessageBox is). Go to your project properties->Linker->Input->Additional Dependencies and add: user32.lib


  • Can't compile this little program!!!