I have just written an QT application using opengl.
When I am compiling the project in Mac OS X I do not have any errors and everything is working fine.
But when I try to compile the project on Ubuntu 10 (with qmake-4.7 [same version as on mac]) compilation fails because:
error: ‘glGenbuffers’ was not declared
This is particularly strange since glxInfo |grep version produces the following output:
OpeGl version string 3.2.9756 Compatibility profil contex
OpenGL shading language version 1.5
…
So from my understanding, glGenBuffers() should be available, right?
Do you have any idea on how to solve this problem?
yes, I have tried glGenBuffersARB (but without including any extra library).
no, I am neither using glew nor glee. I am not even including gl.h (I think qt does that stuff). But the application is running fine on my mac.
There are a few ways around this, the easiest way if you are not distributing any binaries is this:
#define GL_GLEXT_PROTOTYPES
#include "glext.h"
However, depending on how the Qt build was done and your order of includes, glext.h might already be included. So, add to your qmake file the GL_GLEXT_PROTOTYPES define and include glext.h
If you need to distribute your build as a binary, then you are in for some joy. Roughly speaking, you will need to do the get function pointer thing yourself, Qt has a method in QGLWidget/QGLContext to fetch function pointers. If you are more adventurous you can open up GLee for GLEW and hack them to use Qt’s methods…
I will freely admit I don’t think much of Qt (in particular it’s graphics stack). Qt’s support of GL can be best described as out of date at times. The only thing worse in regards to GL use patterns and support than Qt is an older Qt.
Might It be that you have outdated header files? Did you try to look for that definition in your include directories (using grep or other find utilities)?
QtOpenGL includes both gl.h and glext.h, but does not define GL_GLEXT_PROTOTYPES. As to why it builds on Mac and not Linux comes down to that the glext.h header file on Mac OS-X is different than on your Linux distro… additionally, the GL header files on Mac are also structured a touch differently too… special Apple pixie dust.
By the way, what I meant by “did you put the define in the qmake” is the .pro file that qmake uses to produce a Makefile. In my opinion adding the define to the compile string is not as fragile as putting the include before QtOpenGL…