User forums > Using Code::Blocks
Linking GLUT32 with C::B
kostyabkg:
Hi I am trying to compile test files from the redbook for OpenGL with C::B and Dev-C++ and I get the same error:
--- Quote ---Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\b1676805\Desktop\cb\test1\
--------------------------------------------------------------------------------
Switching to target: default
Linking console executable: C:\Documents and Settings\b1676805\Desktop\cb\test1\console1.exe
.objs\hello.o:hello.c:(.text+0x1c): undefined reference to `__glutInitWithExit'
.objs\hello.o:hello.c:(.text+0x37): undefined reference to `__glutCreateWindowWithExit'
.objs\hello.o:hello.c:(.text+0x52): undefined reference to `__glutCreateMenuWithExit'
.objs\hello.o:hello.c:(.text+0x66): undefined reference to `_imp__glClear'
.objs\hello.o:hello.c:(.text+0x87): undefined reference to `_imp__glColor3f'
.objs\hello.o:hello.c:(.text+0x95): undefined reference to `_imp__glBegin'
.objs\hello.o:hello.c:(.text+0xb6): undefined reference to `_imp__glVertex3f'
.objs\hello.o:hello.c:(.text+0xd7): undefined reference to `_imp__glVertex3f'
.objs\hello.o:hello.c:(.text+0xf8): undefined reference to `_imp__glVertex3f'
.objs\hello.o:hello.c:(.text+0x119): undefined reference to `_imp__glVertex3f'
.objs\hello.o:hello.c:(.text+0x120): undefined reference to `_imp__glEnd'
.objs\hello.o:hello.c:(.text+0x127): undefined reference to `_imp__glFlush'
.objs\hello.o:hello.c:(.text+0x159): undefined reference to `_imp__glClearColor'
.objs\hello.o:hello.c:(.text+0x167): undefined reference to `_imp__glMatrixMode'
.objs\hello.o:hello.c:(.text+0x16e): undefined reference to `_imp__glLoadIdentity'
.objs\hello.o:hello.c:(.text+0x19c): undefined reference to `_imp__glOrtho'
.objs\hello.o:hello.c:(.text+0x1e8): undefined reference to `glutInitDisplayMode'
.objs\hello.o:hello.c:(.text+0x1fc): undefined reference to `glutInitWindowSize'
.objs\hello.o:hello.c:(.text+0x210): undefined reference to `glutInitWindowPosition'
.objs\hello.o:hello.c:(.text+0x22d): undefined reference to `glutDisplayFunc'
.objs\hello.o:hello.c:(.text+0x232): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
--- End quote ---
I put glut.h in the include directory, linked the library to libglut32, libopengl32 and libglu32 and this is what I get. I don't know where to look? This is probably some silly mistake of mine however I can't spot it. The test example in both of these IDEs compiles and runs just fine, but not the GLUT...
Thank you!
Kostya.
MortenMacFly:
First of all a little side note:
--- Quote from: kostyabkg on March 03, 2006, 04:39:53 pm ---Linking console executable: C:\Documents and Settings\b1676805\Desktop\cb\test1\console1.exe
--- End quote ---
Your errors are caused by the linker. So it's unlikely they are caused by missing header files. In this case the compiler would complain.
--- Quote from: kostyabkg on March 03, 2006, 04:39:53 pm ---libglut32, libopengl32 and libglu32
--- End quote ---
Please make sure you are using the right order of the libraries you are linking with. This is importeant as they are based on each other. For OpenGL applications one would usually link (in this order) opengl32, glu32, glut32. I guess that's the cause of your problem.
Another side-note: Don't get me wrong, but this is a Code::Blocks forum. Your question is not really related to C::B, isnt' it?! :wink:
With regards, Morten.
Edit: I completely forgot: Are you aware that there is an OpenGL project template shipping with C::B?
Michael:
--- Quote from: kostyabkg on March 03, 2006, 04:39:53 pm ---I put glut.h in the include directory, linked the library to libglut32, libopengl32 and libglu32 and this is what I get. I don't know where to look? This is probably some silly mistake of mine however I can't spot it. The test example in both of these IDEs compiles and runs just fine, but not the GLUT...
--- End quote ---
Did you put the in C::B the correct path(es) to your include and library files?
Best wishes,
Michael
kostyabkg:
Thank you for advice,
However, it seems like the order of linking libraries doesn't affect anything at all. Only when I include gl.h and glu.h files before glut.h it affects the thing. Then error looks like this:
--- Quote ---Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\kostya\My Documents\cpp\test7\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: hello.c
Linking console executable: C:\Documents and Settings\kostya\My Documents\cpp\test7\console1.exe
.objs\hello.o:hello.c:(.text+0x1c): undefined reference to `__glutInitWithExit@12'
.objs\hello.o:hello.c:(.text+0x3c): undefined reference to `__glutCreateWindowWithExit@8'
.objs\hello.o:hello.c:(.text+0x5c): undefined reference to `__glutCreateMenuWithExit@8'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
--- End quote ---
Yes, you are right, I shouldn't post this here, because you are very busy developing C::B and answering the forums posts and this really doesn't relate to C::B, therefore I posted this to OpenGL forum (which I should of done first) http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic&f=2&t=020079
My apologies, gentlemen...
Michael,
I didn't quite understand what you mean by saying
--- Quote ---Did you put the in C::B the correct path(es) to your include and library files?
--- End quote ---
If you are going to answer, check first OpenGL link, maybe somebody answered there. I really respect your work guys and don't want to cause extra hassle.
Kostya.
MortenMacFly:
--- Quote from: kostyabkg on March 04, 2006, 04:27:32 pm ---Only when I include gl.h and glu.h files before glut.h it affects the thing. [...]
--- End quote ---
Mmmh. Sounds strange...?!
Well, here are my suggestions for today:
1.) What OpenGL libraries are you using? Are you sure that they are compatible with GCC? You could give a try to the OpenGL DevPack (search with google please since the download location I got it from seems to have changed).
2.) Do you mix incompatible headers, maybe? Thus you are using OpenGL headers from one package but linking with others?
3.) Did you give a try to the OpenGL template that ships with C::B? This really should work - it has been tested around thousand times or so... ;-)
4.) Could you please post a full compiler log? To enable full logging go into the compiler setup, choose the tab named "other" and set "Compiler logging" to "Full command line". Then post the full log again - this may help, too.
With regards, Morten.
Ps.: There is a NeHe OpenGL lessons thread somehwere else in the forum. You could try if these (simple) projects compile for you.
Edit: Typos... :-(
Navigation
[0] Message Index
[#] Next page
Go to full version