Sign in to follow this  

problem in lesson1

This topic is 4166 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

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 this post


Link to post
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 this post


Link to post
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.obj

Error 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 this post


Link to post
Share on other sites
You probably need to add glu32.lib and opengl32.lib to the additional libraries section in your linker settings.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
I there :)

I downloaded the source code from lesson 1 and when I run the cpp file from the zip file, it compile, build and work good.

When I copy-paste it to a new cpp file I get an error saying that can't create a GL Rendering Context.

This is the 1st time I actually program with OpenGL, untill now I just had read some infos about it, so I don't recognize most of the cmd's.

About the error... I add the libraries in the Project->Settings->Link;
I choosed Win32 Application when starting the new project;
...well...i guess I've done everything all right but I keep receveing the error and the Window doesn't appear :(

Hope you guys can help me

thanks, and take care [[[]]]

Share this post


Link to post
Share on other sites
That's the strange thing..no warnings, no errors :S

I've been using the lesson1 source code I downloaded for my experiences, and everything runs fine, but when I try to make a new opengl window it keeps retrieving that GL rendering context error

Share this post


Link to post
Share on other sites

This topic is 4166 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this