Jump to content
  • Advertisement
Sign in to follow this  
GamerDude27

Errors

This topic is 4214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using some code from Direct Tutorial on Visual C++.
#include <windows.h>    // include the basic windows header file

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nShowCmd)
{
    // create a "Hello World" message box using MessageBox()
    MessageBox(NULL,
               L"Hello World!",
               L"Just another Hello World program!",
               MB_ICONEXCLAMATION | MB_OK);

    // return 0 to Windows
    return 0;
}
My error is:
1>------ Build started: Project: new, Configuration: Debug Win32 ------
1>Linking...
1>tutorial.obj : error LNK2028: unresolved token (0A000029) "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)
1>tutorial.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)
1>C:\Documents and Settings\Ryan\My Documents\Visual Studio 2005\Projects\new\Debug\new.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Ryan\My Documents\Visual Studio 2005\Projects\new\new\Debug\BuildLog.htm"
1>new - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any Ideas what this means?

Share this post


Link to post
Share on other sites
Advertisement
Hi...

I tried to run your code in Visual C++ 6.0 and it worked just great except for the L before the strings. He just refused to compile it in that way. So, the only way I could get it to work was:


#include <windows.h> // include the basic windows header file

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
// create a "Hello World" message box using MessageBox()
MessageBox(NULL,
"Hello World!",
"Just another Hello World program!",
MB_ICONEXCLAMATION | MB_OK);

// return 0 to Windows
return 0;
}




EDIT: Noticed you are using Visual 2005. Is it the express edition? If it is, did you installed Platform SDK? I used to have errors like those while I didn't install it.

Share this post


Link to post
Share on other sites
He probably didn't select a UNICODE build. The L prepend tells the compiler to deal with the string literal as a UNICODE string rather than an ANSI string. A more flexible approach is to wrap string literals with the TEXT macro. That macro prepends the L as needed depending on whether the UNICODE macro is defined or not.

I didn't think that was the problem though because those error messages indicate that a UNICODE build was intended. For example the "wchar_t const *" in the function prototypes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!