PDA

View Full Version : g++ compiler doesn't see functinos inside glx.h



advorak
07-29-2015, 02:38 PM
I have been developing an openGL program. I decided I wanted to use the GLM include library for rotations and whatnot.

When I converted my code to c++, i.e. changed file names to .cpp and used g++ instead of gcc, the compiler complains about the gl functions not being declared in this scope.

I am definitely including the correct header file. I was getting a similar error when compiling under gcc, but I was able to manually declare the GL functions I wanted to use. As long as I linked the library everything was fine.

Now however, I either get the "not declared in this scope" error, or if i manually declare the functions, I get the error at link time of "undefined reference to" all the GL functions.

I am including the "-lGL" directive in my link command.

I have been reading about c++ being more order dependent on library references, but I have placed the link command before the object lib and after the object lib that is causing the problem.

Don't know what to do at this point.

I figured it out. I was not defining the GL_GLEXT_PROTOTYPES for visibility to some functions.

GClements
07-30-2015, 03:50 AM
I figured it out. I was not defining the GL_GLEXT_PROTOTYPES for visibility to some functions.
You're supposed to use glXGetProcAddress() (or a higher-level library such as GLEW) to obtain pointers to those functions, rather than linking to them directly.

That avoids the need for the client library (libGL.so) to be updated in step with the display driver (for direct rendering) or X server (for indirect rendering). If you link to those functions directly, the program will fail to execute if the library doesn't expose the function, even if the function is implemented by the display driver or the X server.