problem in lesson1

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

Recommended Posts

hi, I have downloaded the source code for the NeHe tutorial lesson 1. The .exe file works fine, but when I copy paste the code into a .cpp file and try to compile it I am getting many compiling errors. These are the errors I got :
Error	1	error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [29]' to 'LPCWSTR'	f:\documents and settings\kinder\my documents\visual studio 2005\projects\nehetutorial1\nehetutorial1\nehetutorial1.cpp	80

Error	5	error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'const char [7]' to 'LPCWSTR'	f:\documents and settings\kinder\my documents\visual studio 2005\projects\nehetutorial1\nehetutorial1\nehetutorial1.cpp	102

Error	11	error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'	f:\documents and settings\kinder\my documents\visual studio 2005\projects\nehetutorial1\nehetutorial1\nehetutorial1.cpp	202


A short piece of code where the errors come from :
			// If The Mode Fails, Offer Two Options.  Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE;		// Windowed Mode Selected.  Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE;									// Return FALSE
}
}
}


It seemes like this lesson is working for other people, so I don't see where the error comes from. amoK

Share on other sites
I'm guessing you're using MSVC 2005 as your compiler. Go to your project properties, under general, change the Character Set setting to "Use Multi-Byte Character Set". For an explanation of why see this thread.

Share on other sites

thanks, that did fix the compile errors, but when I tried to run it there were Linker errors :

Error	1	error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z)	nehe.objError	3	error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z)	nehe.obj

Totally there are 14 unresolved symbols.
Has anyone seen this errors berfore?

Thanks again SiCrane for the fast response.

amoK

Share on other sites
My PATH is set corretctly I think if its that what you meen.

Else, where do I find the Linker settings?

Share on other sites
In project properties, there should be a linker folder underneath the C/C++ folder. Under input add the opengl32.lib and glu32.lib to the additional dependencies line.

Share on other sites
That was it.
Thank you for helping me SiCrane.

I sat on this problem for a wile now and decided to ask in this forum and that was a really good decision.

amoK

Share on other sites
Hi, I was having this problem with MSVC 2005 as well, so thanks for the help. However, after following all the posts here I am still left with this linker error message:

MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
D:\My Documents\Visual Studio 2005\Projects\Lesson2\Debug\Lesson2.exe : fatal error LNK1120: 1 unresolved externals

Is this anything to do with the fact I have added this:

/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup

to the Linker/Command Line additional options to prevent a console window? I tried removing it but still got the same error.

Any help would be greatly appreciated

Cheers,
Alex

Share on other sites
Did you select a console application instead of a Win32 app when you created the project? If you did its probably looking for main() instead of WinMain()

Try creating a new Win32 app and importing your source files into it. Dont forget to add the correct libraries to the linker settings.

Share on other sites
Just adding /SUBSYSTEM:WINDOWS to the command line won't work right. You need to go into the project properties under linker options and change the subsystem to windows there.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 37
• 23
• 13
• 13
• 17
• Forum Statistics

• Total Topics
631705
• Total Posts
3001824
×