glGenBuffer was not declared

Hello,

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?

Kind regards,
Harnz

Have you tried glGenBuffersARB? You might have the older API name in your build path. Are you using glew?

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.

unfortunately I have already tried this with no success.

What could be the reason, that the same project builds on mac OS but not on Linux?

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)?

There are 2 hunches that I have:

  1. you included a file that indirectly included glext.h, so make it your very first file to include (after gl.h)
  2. outdated headers, as another has suggested

also adding the define to you qmake file will relax the need for 1), did you put the define in the qmake instead?

thanks for your response, but I am still a little lost…

I do not explicitly include gl.h, therefore I am not quite sure which file to include first.

How do I know whether or not my header files are outdated and how can I update them? Isn’t it unlikely since glxinfo states that I have openGL 3.0?

I do not have any define in my qmake. Can I add this define to my .pro file or where shell I put it?

Thank you.

now it is working. Thank you very much.

I just had to add: #define GL_GLEXT_PROTOTYPES
before I include <QtOpenGL>.

But I still do not know why this was necessary since it was compiling on mac OS without any problems.

Harnz

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…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.