🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

problem in lesson1

Started by
11 comments, last by moinho_vlt 17 years, 11 months ago
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
Advertisement
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.

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
You probably need to add glu32.lib and opengl32.lib to the additional libraries section in your linker settings.
My PATH is set corretctly I think if its that what you meen.

Else, where do I find the Linker settings?
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.
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
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
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.
Member of the NeHe team.
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.

This topic is closed to new replies.

Advertisement