I am using the latest version of MinGW with Code::Blocks 8.02 along with OpenGL 3.1 and GLUT 3.7.
Normally, for GLUT/OpenGL projects, I use Microsoft Visual Studio to compile. I’m looking into cross platform development, however, and so I’ve decided to move many of my OS Portable projects to using GCC 4.4.0 with MinGW to modify the code to work with it. Actually, that was about a month ago.
This is my first time using GLUT on GCC and I’ve tried and failed what feels like 100 times. For every function I use in GLUT, I get a linking error along the lines of:
…\obj\glut.o:glutlib.c:(.text+0x45b)||undefined reference to
__glutInitWithExit'| ..\obj\glut.o:glutlib.c:(.text+0x483)||undefined reference toglutInitDisplayMode’|
…\obj\glut.o:glutlib.c:(.text+0x4d8)||undefined reference to
__glutCreateWindowWithExit'| ..\obj\glut.o:glutlib.c:(.text+0x5a7)||undefined reference toglutInitWindowSize’|
…\obj\glut.o:glutlib.c:(.text+0x60e)||undefined reference to
glutDisplayFunc'| ..\obj\glut.o:glutlib.c:(.text+0x68e)||undefined reference toglutIdleFunc’|
…\obj\glut.o:glutlib.c:(.text+0x70e)||undefined reference to
glutKeyboardFunc'| ..\obj\glut.o:glutlib.c:(.text+0x78e)||undefined reference toglutReshapeFunc’|
…\obj\glut.o:glutlib.c:(.text+0x7cc)||undefined reference to
glutMainLoop'| ..\obj\glut.o:glutlib.c:(.text+0x7ec)||undefined reference toglutPostRedisplay’|
…\obj\glut.o:glutlib.c:(.text+0x80c)||undefined reference to `glutSwapBuffers’|
||=== Build finished: 11 errors, 0 warnings ===|
Yes, I’ve linked in all the libraries needed for GLUT and OpenGL. OpenGL actually works. It seems to link fine…just GLUT doesn’t.
I thought it might be a problem with the libraries I built from source. I obtained another set from online pre-built for MinGW and had the exact same result. I tried with the libraries built as glut32.lib instead of libglut32.a and still had the same result…even after changing the linked library from glut32 to glut32.lib. I even tried changing the “linked libraries” section and putting them into Code::Blocks directly as command line arguments (-lopengl32 -lglut32) and had the same result.
Since I’m not using anything from GLU, I didn’t link the library. I thought that might be the problem and added it in. Of course, it made absolutely no difference. I also tried linking in a whole set of other libraries like winms, gdi and other things I’ve never had to link but that still made no difference.
The following is the command line:
-pg -pedantic -Wmain -O3 -lglut32 -lopengl32
There were also the following pre-defined definitions which I don’t know how to put in the command line:
NOTE: OpenGL was already present in MinGW. I added in GLUT which did not come with the package. Could it be a version mis-match? Doesn’t sound like it from the errors. SDL which didn’t come with MinGW works fine with OpenGL.
My code is strictly closed source (at least for now) but I can post small snippets which I doubt is necessary since this is a linking error.
Using Windows XP SP3 32 bit.