How to link OpenGl in Visual C++ 2010 Express?
I want to do graphics programming using OpenGl and I downloaded the widely recommended Neon Helium tutorials. However, as soon as I tried to Build (I am using Visual C++ Express), I got the following errors:
error LNK2005: _WinMain@16 already defined in lesson1.obj error LNK2005: "long _stdcall WndProc(struct HWND_ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z) already 开发者_开发知识库defined in lesson1.obj fatal error LNK1169: one or more multiply defined symbols found
I'll explain what I did step by step so that it will easier for someone to point out my mistake.
- Downloaded GLUT and GLAUX libraries. Put glaux.h and glut.h in C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl
- Put glut32.lib and glaux.lib in C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
- Created a folder called DLLs wherein I put glu32.dll, glut.dll, glut32.dll and opengl32.dll, and added that folder to my system path.
- Created a new project in VC++ 2010 called Project 1. VC++ creates two source files called Project1.cpp and stdfax.cpp. I then added another .cpp source file named lesson1 and copy pasted the lesson1 code from NeHe in it.
Now when I try to build the project, it gives me the above errors. Could this be because the NeHe tutorials are written for VC++ 6.0? I notice that there are two glut dll files (glut32.dll and glut.dll). Could this be the problem? Should I delete on of them? Also, there isn't a glaux.dll file. Do I have to hunt for it so that my problem will be solved? If anyone can help me solve my problem I'd be really grateful. Many thanks to all the people who answered my previous question
First of all, you should not learn OpenGL with Nehe's Tutorial. While I appreciate what he has done for the OpenGL community in the past, his Tutorials are horribly oudated and deprecated. Consider using this for learning:
http://arcsynthesis.org/gltut/
For your problem: You just have a function already defined in another compilation unit, like the error message states.
Can you upload the whole code to pastebin? Would make helping easier.
But make sure that there is only 1 WinMain in your project. VC2010 most likely created that function for you in the template code.
When creating the project, use the option called "Empty project".
Or you can remove the files created by the wizard and then fight the compiler precompiled header settings.
精彩评论