Skip to main content
GameDev.net gamedev.net
🔒 Locked

Glut library not properly linked in codeblocks

Started by Rimo Jul 30, 2010 at 12:56 PM 6 replies 10.9k views
Original Post
Rimo
Rimo
I'm trying to get glut to work as in this tutorial: http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-2:-Hello-World:-The-Slideshow.html
EDIT: http://www.levelbylevel.com/blog/opengl-c-and-glut-using-codeblocks-and-mingw-updated/ (This is how I learned how to install glut and I assumed the same would work for glew)
However it tells me all references to glut and glew are undefined. I use codeblocks with MinGW as my compiler suite, I installed glut and glew by placing the dll's in system32, copying the headers to their places in the include/GL folder and copying the .libs into MinGW's lib folder.
The linker seems to have no trouble finding the libraries which I included in this order in the projects build options:

opengl32
glu32
glut32
glew32


Also it catches my eye that glewInit() doesn't seem to cause any trouble, but maybe that is a different problem.


This is the entire builder error log:


-------------- Build: Debug in Gloop ---------------

Linking console executable: bin\Debug\Gloop.exe
obj\Debug\main.o: In function glutInit_ATEXIT_HACK':
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../include/GL/glut.h:486: undefined reference to
__glutInitWithExit'
obj\Debug\main.o: In function glutCreateWindow_ATEXIT_HACK':
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../include/GL/glut.h:503: undefined reference to
__glutCreateWindowWithExit'
obj\Debug\main.o: In function glutCreateMenu_ATEXIT_HACK':
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../include/GL/glut.h:549: undefined reference to
__glutCreateMenuWithExit'
obj\Debug\main.o: In function render':
D:/programming/projects/Gloop/main.c:25: undefined reference to
glutSwapBuffers'
obj\Debug\main.o: In function main':
D:/programming/projects/Gloop/main.c:30: undefined reference to
glutInitDisplayMode'
D:/programming/projects/Gloop/main.c:31: undefined reference to glutInitWindowSize'
D:/programming/projects/Gloop/main.c:33: undefined reference to
glutDisplayFunc'
D:/programming/projects/Gloop/main.c:34: undefined reference to glutIdleFunc'
D:/programming/projects/Gloop/main.c:37: undefined reference to
_imp____GLEW_VERSION_2_0'
D:/programming/projects/Gloop/main.c:47: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
10 errors, 0 warnings
Calexus
Calexus
I think you would have better luck getting an answer asking this in the codeblocks forum. And if you haven't already done so you should take a lock at codeblocks "global variables" (check the C::B wiki). You don't have to use them but they make handling library includes a lot easier.
Exitus Acta Probat
Defeatist
Defeatist
I recently tried to port some of my apps from Vista32 to win7x64 and had some similar issues. Make sure all libraries and setttings are the same. IE if you build a win32 executable, make sure you have the glew32 binaries and lib.
Some other things I can think of:
- Make sure you include GLEW first, then glut
- define GLEW_STATIC in the preprocessor
Rimo
Rimo
Quote:
Original post by Calexus
I think you would have better luck getting an answer asking this in the codeblocks forum. And if you haven't already done so you should take a lock at codeblocks "global variables" (check the C::B wiki). You don't have to use them but they make handling library includes a lot easier.


First of all, thanks for the help.

I looked through the codeblocks forums already and found the same problems but the solutions didn't work for me. (Solutions involved installing the right distribution of GLUT apparently, but I am positive I did that and I actually tried some of the distributions that apparently shouldn't work.)

Also since I have reproduced this exact same problem by trying to build the project in eclipse with MinGW, I'm sure the problem must lie elsewhere. I think it's MinGW but I have no clue how to proceed with solving that.
Orione
Orione
I had exactly your same problems 2 days ago, and after 2 days of bad headaches I solved every problem by using freeglut (http://freeglut.sourceforge.net/).

Then I also had to add

#define GLUT_DISABLE_ATEXIT_HACK

before

#include

All problems disappeared and a SolidTeapot magically appeared on my glut window.

Hope this can help you.
Rimo
Rimo
Thank you, freeglut seems to work amazingly well.
I use dev-c++ now though and installed it with a devpak as I really want to get back to learning more openGL again.

I do however get this error now and googling it only brings up this thread as result :S :

[Linker error] undefined reference to `_imp____GLEW_VERSION_2_0'

[Edited by - Rimo on August 2, 2010 9:56:32 AM]
Orione
Orione
Never used glew, but why not to start right now?
So I tried and maybe this could help you too (and make me to gain some positive feedback points ;=))

This thread (replies from indigo0086 and Trenki)
http://www.gamedev.net/community/forums/topic.asp?topic_id=462433
may point you to the right way to solve your problem.

This link is also useful:
http://old.nabble.com/glew32.a-for-MinGW-td24058494.html

Some useful tools and instructions:
http://oldwiki.mingw.org/index.php/CreateImportLibraries

But HEY!!! Version 1.5.4 is not so old at all!
So if someone just did the work why not to thank him and use his results?

Here you go to THE solution:
http://julianibarz.wordpress.com/2010/05/12/glew-1-5-4-mingw32/
http://www.mediafire.com/?20tlnt0eytt

Then of course you still need to point your compiler to the right directory for .a file and glew.h and to add
#include
to your code

p.s.: I would suggest you to go back to Code::Blocks, or at least to use wxDevCpp, as Dev-Cpp last version goes back to February 2005.
Anyway this is just your choice, but maybe it will be not so easy to find help on old and less supported ide.
Rimo
Rimo
I'll give the last one a try now.

Also I tried to go back and pointed codeblocks to every executable in the working MinGW folder of dev-c++.

I actually installed mingw manually before so I could use it in eclipse but I wanted another IDE. I also wrote code there that created me a window just how I wanted it and also wrote code to register any keyboard input. But I just can't seem to get anything done on this new tutorial since I changed my IDE. :S

I honestly can't understand why glewInit gives no error message but GLEW_VERSION_2_0 doesn't. I tried verifying that it was not the linking or headers by simply renaming the glew library for a while, which resulted in obvious errors, and once by removing the header inclusion and it gave errors on both the function and defined constant. However, with the header included it has this weird _imp____ prefix.

I just want to get back to learning openGL again :(

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.