PDA

View Full Version : gl3w- undefined reference to 'glXGetProcAddress'



PrestoChung
04-12-2012, 08:28 AM
Trying to convert a project onto Linux that uses gl3w.

I have #include "GL3/gl3.h" and #include "GL3/gl3w.h"

I link to "-lgl3w" but I get this error on linking:


libgl3w.so: undefined reference to 'glXGetProcAddress'

Are there more files or libraries I need to include?

Alfonse Reinheart
04-12-2012, 11:15 AM
Are you including X11 and OpenGL? Because glXGetProcAddress is not part of GL3W.

PrestoChung
04-12-2012, 01:52 PM
Okay so now I added -lGL to the linker and I no longer get the error.

So far the only problem I notice is that I am getting a 2.1 context instead of a 3.x or 4.x...

Edit:
Hmm noticing that gl3wInit() returns -1...some sort of problem there.

Edit2:
gl3w only gave me the libgl3w.so file and gl3w.h, gl3w.c, and gl3.h...am I still missing some kind of opengl library file? I just added -lGL to the linker...but is that not the right library?>>

Edit3:
I noticed this is the output of my glGetString GL_VENDOR, GL_VERSION, etc. shows onboard graphics, not the discrete Nvidia card:

Tungsten Graphics, Inc
Mesa DRI Intel(R) Sandybridge Mobile
2.1 Mesa 7.11

PrestoChung
04-23-2012, 12:25 AM
Update:

So I found I had to disable integrated graphics in the BIOS in order to get the proper GL Context with the discrete graphics hardware.

But, when I have added back in 'gl3wInit()' (it was not there before), the 'glXGetProcAddress' error returns.

I have linked the following
-lSDL2 -lGL -lGLU -lgl3w -lX11
but to no good... I tried to link to -lGLX, but it is not found as a library.

When I search repositories I can see I have 1 GLX runtime installed...


$ aptitude search GLX
i libgl1-mesa-glx - free implementation of the OpenGL API -- GLX runtime
p libgl1-mesa-glx-dbg - Debugging symbols for the Mesa GLX runtime
p libswt-glx-gtk-3-jni - Standard Widget Toolkit for GTK+ GLX JNI library
p libva-glx1 - Video Acceleration (VA) API for Linux -- GLX runtime
p libxcb-glx0 - X C Binding, glx extension
p libxcb-glx0-dbg - X C Binding, glx extension, debugging symbols
p libxcb-glx0-dev - X C Binding, glx extension, development files
p rss-glx - Really Slick Screensavers GLX Port

Must I install another?

How do I link to the GLX library so to fix the error that 'glXGetProcAddress()' is not found??

ZbuffeR
04-23-2012, 08:24 AM
According to this : http://dri.freedesktop.org/wiki/glXGetProcAddressNeverReturnsNULL

glXGetProcAddress does not have to be exported, but glXGetProcAddressARB must be.

PrestoChung
04-23-2012, 05:28 PM
How can I change the gl3w to use ARB instead of regular??

When I do 'scons' in the gl3w directory, it generates the gl3w.c file at the same time as libgl3w.so. So if I change gl3w.c at this point, libgl3w.so is already built. I try to rebuild, but it re-builds the gl3w.c, un-doing my change.

See the error is in libgl3w.so:

g++ -o debug/runme_d debug/base.o debug/bitmask.o debug/context.o debug/entity.o debug/history.o debug/intro.o debug/main.o debug/program.o debug/rangeset.o debug/renderer.o debug/storage.o debug/subsystem.o debug/timer.o debug/title.o -lSDL2 -lGL -lgl3w
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libgl3w.so: undefined reference to `glXGetProcAddress'

Is that the wrong libgl3w.so? The one I built is in a different directory (/usr/lib):
$ ls /usr/lib | grep libgl3w
libgl3w.so

But, I suspect it still has the same problem since I cannot change it to use the ARB function.

PrestoChung
04-23-2012, 08:27 PM
See the error is in libgl3w.so:

g++ -o debug/runme_d debug/base.o debug/bitmask.o debug/context.o debug/entity.o debug/history.o debug/intro.o debug/main.o debug/program.o debug/rangeset.o debug/renderer.o debug/storage.o debug/subsystem.o debug/timer.o debug/title.o -lSDL2 -lGL -lgl3w
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libgl3w.so: undefined reference to `glXGetProcAddress'

Is that the wrong libgl3w.so? The one I built is in a different directory (/usr/lib):
$ ls /usr/lib | grep libgl3w
libgl3w.so

But, I suspect it still has the same problem since I cannot change it to use the ARB function.



Ok. So i found that the gl3w.c file is generated from the python script that came with gl3w repo, so I was able to edit that line in the script and change it to glXGetProcAddressARB, rebuild the library and copy it into the include and lib folders.

I also found the glx library in some sub-folders of my /usr/lib directory

However, even when I link to glx successfully, I still get the same undefined reference, to the ARB function and regular function:
g++ -o debug/runme_d debug/base.o debug/bitmask.o debug/context.o debug/entity.o debug/history.o debug/intro.o debug/main.o debug/program.o debug/rangeset.o debug/renderer.o debug/storage.o debug/subsystem.o debug/timer.o debug/title.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/xorg/modules/extensions -lSDL2 -lGL -lGLU -lglx -lxcb-glx -lgl3w -lX11
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libgl3w.so: undefined reference to `glXGetProcAddressARB'
collect2: ld returned 1 exit status

I probably don't need to link to all of those libraries...but still the error!