weird linker problems in DevC++

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(&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(.text+0x1c) In function `glutInit_ATEXIT_HACK': 
  [Linker error] undefined reference to `__glutInitWithExit@12' 
 C:\DOCUME~1\LEV~1.WOW\LOCALS~1\Temp\ccCccaaa.o(.text+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.

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

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-

Did you install glut 3.7.6+ DevPak ?

It works for me.
==song==

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 toglutInitDisplayMode@4’
[Linker error] undefined reference to glutInitDisplayMode@4' [Linker error] undefined reference toglutInitWindowSize@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.

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==

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

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.

I finally managed it to work in freeGlut. Don’t ask me how, but it’s ALIVE!! :-)).