Wednesday, July 22, 2009

Getting GLUT Working With Code::Blocks in Windows (Vista)

Look at my last post to see the status of things when I last beat my head against this problem.
I couldn't find anything useful to help me with finding "-lGL" in Windows, I really don't think that even makes sense. So, I decided to try creating a new GLUT project in Code::Blocks, maybe there was something wrong with my current project. Afterall, I'd started it in Code:Blocks for Linux and then just opened up that project file on my Windows machine.
I ran into the same problem that had caused me to start working under Linux in the first place. I couldn't get Code::Blocks to see my GLUT libraries, and thus I couldn't even create the project. On the second page of the GLUT project creation wizard I kept one or another of a few different errors, all complaining about the directory I was giving in the input for "Please select GLUT's location:".
First off, it's the binary version that you want if you follow these instructions.
The trouble stems from the fact that the GLUT zip file that you download does not have the dierctory structure expected by the IDE. The same is true for MS VC++; in fact I found the solution in a tutorial which uses MS VC++. That's a video tutorial, and the helpful part starts around 1m:40s into it. To fix it, create the following directory structure and place your files within it as shown:
GLUT
include
GL
glut.h
lib
glut.def
glut32.dll
glut32.lib
README-win32.txt
It doesn't matter where you put this, and you can name that top level "GLUT" directory whatever you want. Obviously the README file doesn't actually matter. Once this has been done, copy the full path to the GLUT (or whatever you name it) directory into the input in the Code::Blocks project creation wizard and then click 'Next >'. It should let you advance to the next step. So, now it's finally working for me. Before I copy in all the code I wrote in Linux I hit F9 once to make sure all is well in this new, empty project.
FAIL.
GL\glut.h|50|error: redeclaration of C++ built-in type `short'
GL\glut.h|58|warning: ignoring #pragma comment
GL\glut.h|66|warning: ignoring #pragma comment
GL\glut.h|67|warning: ignoring #pragma comment

Goddamnit! There are some hits on the Googelz for this. Did you know GLUT hasn't been maintained since 1999? Great kuugley mooglee, I hate this shit.
Guess I'll work on this again tomorrow.

No comments: