PDA

View Full Version : weird linker problems in DevC++



Entheogen
12-17-2005, 07:37 PM
I am a newbie to opengl, and haven't even compiled one program using it because my compiler keeps giving me these weird linker errors.

I put all needed .h and .lib files where needed (C:\Dev-Cpp\include and C:\Dev-Cpp\lib).

Here is the specific program in question, although very similar problems are present in all other gl code i tried to compile:


#include <windows.h>

#include <GL/glut.h>
#include <GL/gl.h>




int main(int argc, char **argv) {
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);



glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
//UpdateTheWindowAndCheckForEvents();
}and here are the linker's complaints:

C:\DOCUME~1\LEV~1.WOW\LOCALS~1\Temp\ccCccaaa.o(.te xt+0x1c) In function `glutInit_ATEXIT_HACK':
[Linker error] undefined reference to `__glutInitWithExit@12'
C:\DOCUME~1\LEV~1.WOW\LOCALS~1\Temp\ccCccaaa.o(.te xt+0x3d) In function `glutCreateWindow_ATEXIT_HACK':
[Linker error] undefined reference to `__glutCreateWindowWithExit@8' There are a lot more. Basically linker complaints about every gl and glut function.

I am at a loss here, and all of this is very frustrating and confusing.

dasraiser
12-18-2005, 04:14 AM
Seasons Greetings

Linking to the gl/glut dll's require the .lib files to be added to the additional libraries in the projects settings, this tells the compiler how to handle the functions in the dll.

hope this helps

regards

dasraiser

Ehsan Kamrani
12-18-2005, 05:19 AM
In VC++ i write the following commands to link the OpenGL libraries to my project

#pragma comment( lib, "opengl32.lib" )
#pragma comment( lib, "glu32.lib" )
#pragma comment( lib, "gluaux.lib" )
#pragma comment( lib, "glut32.lib" )

-Ehsan-

songho
12-18-2005, 06:29 PM
Did you install glut 3.7.6+ DevPak (http://www.nigels.com/glt/devpak/) ?

It works for me.
==song==

Goran
12-21-2005, 05:26 AM
I tried same code and I get same errors. there are 4 of them:
[Linker error] undefined reference to `glutInit@8'
[Linker error] undefined reference to `glutInitDisplayMode@4'
[Linker error] undefined reference to `glutInitDisplayMode@4'
[Linker error] undefined reference to `glutInitWindowSize@8'
I have installed glut 3.7.6+ DevPak and my linker line is -lopengl32 -lglu32 -lglut32. I have same problem with all others prorgams thas use Glut. OpenGl works just fine.

songho
12-21-2005, 07:08 AM
Have you recently updated any DevPaks related with MinGW, such as Win32API, or MinGW runtime?
I guess that some conflicts cause GLUT errors.

Try re-install Dev-C++ and glut Devpak only. OR, re-install the glut pak after other DevPaks installed. Then run a test program if it works or not.

Other option is using freeglut or OpenGlut instead.

I have on my system;
Dev-C++ v4.9.9.2
Win32API v3.2
glut v3.7.6+

And it works without a problem. Hope it helps.
Regards.
==song==

Goran
12-21-2005, 09:49 AM
I reinstaled whole dev cpp, then reinstaled Glut devpack then tryed openGlut and still nothing. same thing. I have slight feeling that I missed something but today I cant think anymore. Tommorow I'll try again. I did everything step-by-step as it is writen in all documents and still nothnig. Over&out

12-22-2005, 03:26 AM
Did you put it under the correct include directory? I have a \Vc7\PlatformSDK\Include\gl directory aswell as a Vc7\include\ for me it worked in the first one.

Goran
12-22-2005, 05:18 AM
I finally managed it to work in freeGlut. Don't ask me how, but it's ALIVE!! :-)).