On Tue, Mar 20, 2012 at 09:02:13AM +0000, Edd Barrett wrote: > Hi, > > Having spoken to sthen and djm, I am still stuck on this, so I am posting on > ports, incase someone here knows. > > Im looking at porting something which uses ctypes to load first libGL and then > libGLU. Once we strip the gunk away, the library loading looks like this: > > ---8<--- > import ctypes > ctypes.cdll.LoadLibrary("libGL.so") > ctypes.cdll.LoadLibrary("libGLU.so") > ---8<--- > > Try it on a python shell. The final line spews errors about missing > symbols: > > ---8<--- > python2.7:/usr/X11R6/lib/libGLU.so.7.0: undefined symbol 'glPixelStorei' > python2.7:/usr/X11R6/lib/libGLU.so.7.0: undefined symbol 'glEvalPoint2' > python2.7:/usr/X11R6/lib/libGLU.so.7.0: undefined symbol 'glMultMatrixd' > python2.7:/usr/X11R6/lib/libGLU.so.7.0: undefined symbol 'glPopAttrib' > ... > ---8<--- > > These symbols are from libGL.so (i used nm to check this), which we supposedly > loaded on the previous line. > > I have used LD_DEBUG to check libGL is correctly loaded, and it is, log > here: > http://theunixzoo.co.uk/files/pylog > > I can even see the functions from the python interpreter: > >>> libgl = ctypes.cdll.LoadLibrary("libGL.so") > >>> libgl > <CDLL 'libGL.so', handle 80270010 at 7c08f8ac> > >>> libgl.glEnd > <_FuncPtr object at 0x7c07402c> > > If you use LD_PRELOAD, all is well: > > ---8<--- > % LD_PRELOAD=/usr/X11R6/lib/libGLU.so.7.0 python2.7 > Python 2.7.2 (default, Mar 16 2012, 06:30:10) > [GCC 4.2.1 20070719 ] on openbsd5 > Type "help", "copyright", "credits" or "license" for more information. > >>> import ctypes > >>> ctypes.cdll.LoadLibrary("libGLU.so") > <CDLL 'libGLU.so', handle 20ec934f8 at 201f50790> > ---8<--- > > So, why the undefined symbol errors? Any ideas? > > -- > Best Regards > Edd Barrett > > http://www.theunixzoo.co.uk >
Hi, I think you want RTLD_GLOBAL flag, by default RTDL_LOCAL is used. >>> ctypes.CDLL("libGL.so", ctypes.RTLD_GLOBAL) <CDLL 'libGL.so', handle 201136080 at 20c6454d0> >>> ctypes.CDLL("libGLU.so", ctypes.RTLD_GLOBAL) <CDLL 'libGLU.so', handle 209051308 at 20c645dd0>