1

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.

  1. Downloaded GLUT and GLAUX libraries. Put glaux.h and glut.h in C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl
  2. Put glut32.lib and glaux.lib in C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
  3. 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.
  4. 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

1

2 Answers 2

1

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.

1
  • Thank you very much for your advice. I think I have bitten off more than I could chew by trying to jump straight into OpenGl. I'm a programming noob. The only computer programs I have written are MATLAB ones to solve PDEs and that hardly counts as programming. I think I will be better off first getting the basics of Visual C++ down pat. Thank you very much!
    – Salil
    Commented Jul 31, 2011 at 20:34
0

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.

1
  • Thank you very much for your advice. I think I have bitten off more than I could chew by trying to jump straight into OpenGl. I'm a programming noob. The only computer programs I have written are MATLAB ones to solve PDEs and that hardly counts as programming. I think I will be better off first getting the basics of Visual C++ down pat. Thank you very much!
    – Salil
    Commented Jul 31, 2011 at 20:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.