Hard Light Productions Forums

Off-Topic Discussion => Programming => Topic started by: Kosh on September 13, 2009, 09:32:16 am

Title: OpenGL
Post by: Kosh on September 13, 2009, 09:32:16 am
So at the tail end of summer we have a couple of weeks where we take a (mandatory) CS project class using Visual C++ 6.0 MFCs. I got that part all done, but for the welcome screen I wanted to do a little more by having an OpenGL animation of somekind. I looked at  this (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19) and it seems similair to what I wanted to do, so I thought I would copy the code (and the Data folder) to a new empty project to play around with it and learn more about how it works. Problem, upon compiling this empty project I get 25 linking errors (24 of which saying I have unresolved externals and one of which saying it can't link). Why is it doing this? Keep in mind I didn't actually make any changes yet since I needed to see if it could execute in a new project.
Title: Re: OpenGL
Post by: portej05 on September 13, 2009, 10:49:09 am
My guess is that you haven't linked against the opengl libraries.

But please! We're not psychic - post the errors!


(and please, get yourself a better compiler :D )
Title: Re: OpenGL
Post by: Aardwolf on September 13, 2009, 09:34:54 pm
Yeah, linker errors are annoying. You've got to figure out how your specific IDE wants you to set stuff up. It's hell.
Title: Re: OpenGL
Post by: Stormkeeper on September 14, 2009, 03:22:55 am
Haha, nehe. Brings back memories.

Just to find out, you working with GLUT?
Title: Re: OpenGL
Post by: Kosh on September 14, 2009, 07:52:21 am
I included the OpenGL libraries at the beginning of the code. Actually all the code is the same, I didn't change anything, I just copied it to an empty win32 application project. All the linker errors seem to be from gl stuff, which makes no sense to me.
Title: Re: OpenGL
Post by: portej05 on September 14, 2009, 08:17:56 am
What you've done is to include the headers.
Those headers refer to functions in an external library.
Without knowing more about your setup though, we can't really help you further.
At a minimum, you'll need to link against the windows libraries and opengl32.lib.
Title: Re: OpenGL
Post by: Stormkeeper on September 14, 2009, 08:31:10 am
Generally, I used to set the files that I'm linking in a seperate header.h. Also, the order in which you include the headers might cause some errors and the like.
Title: Re: OpenGL
Post by: portej05 on September 14, 2009, 09:01:32 am
Stormkeeper: It's a linker error, not an include error.
Kosh, please post the errors!
Title: Re: OpenGL
Post by: Stormkeeper on September 14, 2009, 09:33:53 am
I know, but I do remember getting a linker error before for including some glut header before a standard windows library. Since he's working with OpenGL, there's a chance he might be working with glut so ...
Title: Re: OpenGL
Post by: Kosh on September 15, 2009, 04:43:56 am
Stormkeeper: It's a linker error, not an include error.
Kosh, please post the errors!

Right here:

--------------------Configuration: opengl practice - Win32 Debug--------------------
Linking...
practice.obj : error LNK2001: unresolved external symbol _auxDIBImageLoadA@4
practice.obj : error LNK2001: unresolved external symbol __imp__glTexImage2D@36
practice.obj : error LNK2001: unresolved external symbol __imp__glTexParameteri@12
practice.obj : error LNK2001: unresolved external symbol __imp__glBindTexture@8
practice.obj : error LNK2001: unresolved external symbol __imp__glGenTextures@8
practice.obj : error LNK2001: unresolved external symbol _gluPerspective@32
practice.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
practice.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
practice.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
practice.obj : error LNK2001: unresolved external symbol __imp__glHint@8
practice.obj : error LNK2001: unresolved external symbol __imp__glBlendFunc@8
practice.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
practice.obj : error LNK2001: unresolved external symbol __imp__glDisable@4
practice.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8
practice.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
practice.obj : error LNK2001: unresolved external symbol __imp__glShadeModel@4
practice.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
practice.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
practice.obj : error LNK2001: unresolved external symbol __imp__glTexCoord2d@16
practice.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
practice.obj : error LNK2001: unresolved external symbol __imp__glColor4f@16
practice.obj : error LNK2001: unresolved external symbol __imp__glClear@4
practice.obj : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4
practice.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
practice.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4
Debug/opengl practice.exe : fatal error LNK1120: 25 unresolved externals
Error executing link.exe.

opengl practice.exe - 26 error(s), 0 warning(s)


Here was my setup, dl the visual c++ version of that program, then copy the source code (not the .cpp file). Then create a new blank win32 application, then create a new source code file. then paste the text. Also copy the Data folder and put in your new project folder, don't change the name or anything. That's what I did.
Title: Re: OpenGL
Post by: portej05 on September 15, 2009, 06:04:44 am
You're not linking against the opengl32.lib library (which on Win32 loads and uses opengl32.dll)

Under VS2008, you go to the project options and then additional dependencies under the linker settings and add 'opengl32.lib', but since you're using VC6, I'm not sure.
Title: Re: OpenGL
Post by: Kosh on September 15, 2009, 08:31:39 am
Any idea where I can find out?
Title: Re: OpenGL
Post by: Kosh on September 15, 2009, 10:48:26 pm
Ok, I figured it out. Thanks guys. Now to wrestle with animations......
Title: Re: OpenGL
Post by: Stormkeeper on September 16, 2009, 01:02:34 am
T'was a linker error in the end. :p