View Full Version : GLUT problem

07-09-2002, 03:52 PM
im new to programming with opengl, and im using GLUT for windows. I use gcc for windows to compile, but when i compile, it throws me some errors:
C:\windows\temp\ccZAufgb.o(.text+0x2ea):cuad.c: undefined reference to `glutMainLoop'

It throws many of this errors more than 10.
This is how i compile it with the gcc:

gcc myprog.c -o myprog.exe -Iincludedir -Llibrariesdir -lglut32 -lglu32 -lopengl32

I've also tried using -lglut but its the same, any ideas on this?

If someone can help me i will be very appreciated, since i really want to learn how to program in opengl
Sorry for my poor english but im from Argentina

07-09-2002, 10:49 PM
Hi !

First check if you have the glut library, if not then that explains it, it could also be the order of the libraries, ld is picky about this so it's possible that you must put -lglut at the end.


07-10-2002, 06:16 AM
Thanks for the answer, but nope, its the same wherever i put it, ive tried all the combinations posible and keeps saying the same 18 errors
Ive got all the libraries (i guess), i have

Dinamic (in windows\system):

static (in my defined directory):

07-11-2002, 09:15 PM
You can remove glut.dll and glut.lib if you have not installed SGI's OpenGL implementation. The glut32.lib is for Microsoft's compiler but probably works. The problem is that you are using -lglut32 so the the system will look for libglut32.a. The easiest is to rename glut32.lib but I think that a command line with glut32.lib will also work.

Some corrections:
- glut32.lib is not a pure static library it is a import library
- Mikael givs the logical but incorrect order. http://www.opengl.org/discussion_boards/ubb/smile.gif See http://users.actcom.co.il/~choo/lupg/tutorials/libraries/unix-c-libraries.html#link_order

07-12-2002, 09:42 AM
Thx for th link Zico!, its good to know this kind of info http://www.opengl.org/discussion_boards/ubb/smile.gif
still, how do i know which library uses stuff from another?, do i have to open them and see the functions it uses?

im using the port for windows of the GNU gcc, so it shouldnt look for libglut32.a, am i right?, still ive changed the name of glut32.lib to libglut32.a and still the same errors. Ive also tried using -lglut32.lib instead of -lglut32 but tells me no such file or directory

07-12-2002, 10:09 PM
I do not know how to find out which library uses stuff from another. In most cases do you know it anyway like GLUT is using stuff from OpenGL. If you have to rearrange the order will the linker give a error message anyway. This is not the solution here since GLUT is not used in the other libraries.

The compiler should look for libglut32.a if you told it to do so with -lglut32. Strange that it did not work even if you renamed the file. If you have a glut32.lib should you not use -lglut32.lib but something like
gcc myprog.c -o myprog.exe -Iincludedir -Llibrariesdir glut32.lib -lglu32 -lopengl32
Do the above work if you place a copy of glut32.lib in the same directory?

Perhaps is the compiler not installed correct? Can you build the first 5 of NeHe's tutorials? (with the -mwindows switch)

07-13-2002, 01:44 AM
I have the same problem, thought I get a LOT of linking errors.

07-13-2002, 10:03 AM
i gonna commit suicide one of this days

i tried again renaming glut32.lib to libglut32.a and saw a line that passed too fast in the DOS window cause of the error lines it throws after, it said something like this:

'glut32.lib' its not supported by this configuration of GCC

sorry for missing that meaningless line http://www.opengl.org/discussion_boards/ubb/rolleyes.gif http://www.opengl.org/discussion_boards/ubb/redface.gif
Then i went to try and compile it with Borland C++ 5.5.1 command line, but kept saying this:

Error E2209 myprog.c 1: Unable to open include file 'stdlib.h'
Error E2209 myprog.c 2: Unable to open include file 'GL\glut.h'

even though the headers where in the corresponding directories!

So please Zico, any ideas on how to solve this problem or of a good compiler that doesnt take too much space cause i dont wanna waste 300megs just for a compiler?

Perhaps is the compiler not installed correct? Can you build the first 5 of NeHe's tutorials? (with the -mwindows switch)

sorry but i dont know whats that Nehe tutorial or where to get it, the program im trying to compile is one taken from the book OpenGL: Programming Guide Third Edition

are you using the same compiler i am?

[This message has been edited by Batsu (edited 07-13-2002).]

07-13-2002, 10:38 PM
The errors from Borland certainly indicates that it is not installed correct. Try first to compile a little hello world program. Perhaps is the enviroment variable not right.

Even if the files has the same name so is the format for Borland and MSVC .lib files different. You need to convert glut32.lib with coff2omf for Borland.

07-14-2002, 12:37 AM
I have the gcc compiler which comes with Bloodshed's Dev-C++ IDE.
It is no problem to compile opengl projects
(including NeHe's tutorials), but glut just wont work.

07-18-2002, 08:37 AM
same errors again and again, do i installit again?, i guess theres no problem if i change the default path where it installs it, right?

To import libraries to borland, shouldnt i use the implib command?