I have had the same problem(s) lastly, since I work a lot with OpenGL these last months.
There are probably several troubles to address.
I assume you use GCC compiler (with library in "libxxxx.a") on Windows (because of gdi32...)
1 - the order of the libraries is probably wrong. You should try this order:
- glew
- glut
- glu32
- opengl32
- winmm
- gdi32
2 - naming convention of the lib: for GCC, if you use a library in ".lib", gcc has a lot of troubles to find it.
This is also not a good idea to mix Visual Studio ".lib" and gcc ".a" libraries. Stick to gcc libraries. The best way is to avoid giving extension ".a" on the command line
Your linker should look like that:
glew32
glut32
glu32
opengl32
winmm
gdi32
3 - do no make the confusion between glu & glut. These are 2 different libraries. If you use GLUT, you will need GLU.
4 - be careful when including opengl headers on Win32. windows.h must be included BEFORE opengl and all opengl libraries:
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glew.h>
#include <gl/glut.h>
5 - for glut at least, you have to make sure you are using the correct library (static linking versus dynamic linking)
There is a compiler directive to define if you are using the static version (defined in gl/glut.h). You have also to make sure that the linker is using the correct version of the library.
If you fail on this step, you will have a lot of "undefined reference : imp___xxxxx missing" kind of mistakes
Here are the steps to link GLUT statically: (assuming FreeGlut, same apply for GLUT)
- define in your project command line FREEGLUT_STATIC (menu project / build options, tab "compiler settings", tab "#define", add FREEGLUT_STATIC here)
- make sure the glut libraries are correctly named (libfreeglut-static.a and libfreeglut.a) and use the correct one in the linker command line
EDIT: for GLEW as well, you need to define #define GLEW_STATIC if you are using the static version of the lib. See here:
http://forums.codeblocks.org/index.php?topic=7322.0;wap2 Or use Glee (easy setup, same functionnality)
6 - you can use the GLUT template in codeblocks. It works quite good with the original GLUT, and it can show you the right direction
7 - see NeHe tutorials for step-by-step settings of OpenGL. A bit outdated, but perfect for beginners (I have started here also, 8 month ago)
As a side note, this is not Codeblocks related. If you are still stuck, try to search the web, and / or start with a simpler project
Good luck !
Sebastien