Hi, folks, I installed a new IDE called Code::Blocks after using DevC++ quite a while and now I´ve almost completely moved to use Code::Blocks. I love it. However, linking OpenGL & GLUT turns out to be very frustrating - things just don´t work. I did some research, tried this one out: http://www.allegro.cc/forums/thread/596253
And of course, it doesn´t work. Nice. Friggin' beautiful. Could somebody help me out here? Using OpenGL and GLUT would be a very welcome thing for me, I need it.
Oh, and if I have to download some files (pretty surely I have to), please send me download links too, because not all versions of the specific files work together (latest ones, please).
F:\Programs\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\include\GL\glut.h|455|undefined reference to `_imp____glutInitWithExit@12'|
F:\Programs\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\include\GL\glut.h|472|undefined reference to `_imp____glutCreateWindowWithExit@8'|
F:\Programs\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\include\GL\glut.h|518|undefined reference to `_imp____glutCreateMenuWithExit@8'|
F:\Programs\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\include\GL\glut.h|472|undefined reference to `_imp____glutCreateWindowWithExit@8'|
F:\Programs\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\include\GL\glut.h|518|undefined reference to `_imp____glutCreateMenuWithExit@8'|
F:\Programs\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\include\GL\glut.h|472|undefined reference to `_imp____glutCreateWindowWithExit@8'|
In total, 24 errors, 18 warnings
I included these:
gl.h
glu.h
glut.h
And these are my libraries I linked (in order I put them in, as in relative path):
libglut32.a
libglu32.a
libopengl32.a
libgdi32.a
libwinmm.a
And these I have in System32 folder (I´m using Windows Vista):
glu32.dll
glut32.dll
opengl32.dll
Do you definitely have the most recent version of Code::Blocks, as those errors appear to be in the OpenGL headers themselves. Coincidentally, since you're on Windows, you could also try Visual C++ Express, just to see if the problem is limited to the headers with Code::Blocks. Did you not get this issue in DevC++?
Although I linked files bit differently in DevC++, there were no errors or warnings. I use Code::Blocks, because I want to create as portable code as possible (OpenGL/GLUT is used for the same reason) and to my knowledge, Visual C++ Express or Visual Studio are mostly Microsoft specific - or, are they? Oh, and Code::Blocks is up-to-date, DevC++ isn´t and I have the recent version of Code::Blocks right now.
Wasn't "libglut32.a" depricated or something like that? Which tutorial are you working off of OP?
By the way, the IDE itself Dev-C++ isn't installable cross-platform (because it's written in Pascal?). Actual compatiblility or your applications would be determined by your compiler, which I see in mingw and the libs that you use.
If you plan on distributing for Linux, it seems that a lot of people just drop the source code in a tar ball anyway and that precompiling it leads to more and more issues.
Visual C++ Express or Visual Studio are mostly Microsoft specific
Well if you are careful, code written in Visual Studio can still be portable, though there are of course vendor specific features as well. I only was suggesting this to see if you avoided the problem by using the OpenGL header file from a different vendor. I wasn't suggesting you need swap permanently :P
Code::Blocks is up-to-date, DevC++ isn´t and I have the recent version of Code::Blocks right now
Quite right too. I would never suggest someone used Dev C++ over Code::Blocks.
Do you still get these errors when you comment out most of your source code, just leaving a basic main function and the three OpenGL headers?
It seems to like that GLUT is the only one that doesn´t work. When I include these...
1 2
#include <GL/gl.h>
#include <GL/glu.h>
...compiler doesn´t warn of display any erros, but after I put this after those...
#include <GL/glut.h>
...it doesn´t work.
And unfortunately, changing the order as you suggested stahta01 doesn´t work either.
So, has anyone even managed to succesfully link OpenGL and GLUT files in Code::Blocks?
I can tell you that you probably don't need it. I mentioned that it might be depricated because looking back at my past projects I saw that I had it commented out with a note saying "Not Needed". These were all functioning mini games by the way.
I can't help with GLUT, sorry. But I could suggest alternate libraries for window management. You could use either SDL (http://www.libsdl.org/) or SFML (http://sfml-dev.org/) to set up the window. Both have integrated graphics capabilities, but both also support use of OpenGL directly. I suggest SFML :)
+1 Xander314 for SFML, you can learn how to create a rendering context in SFML in a weekends time. It also works VERY well with OpenGL and has a really straight forward well organized tutorial on the website.