JF002
Posts: 94
Joined: Sat Feb 04, 2012 8:49 am
Contact: Website

Ctypes, doesn't load the good lib

Thu Jan 24, 2013 6:21 pm

Hi!

In order to use OpenGL ES with Python using Ctypes, I try to load /opt/vc/lib/libGLESv2.so.

This code works fine, it prints the GL_VERSION string.

Code: Select all

from ctypes import *
gles = CDLL("libGLESv2.so.2")
string = ptr(0x1f02) #GL_VERSION
print(str(string))
However, I don't understand why:

Code: Select all

print(find_library("GLESv2"))
returns libGLESv2.so.2, which seems to reside in /usr/lib/arm-linux-gnueabihf/.

The problem is that the first code using this library in /usr/lib/arm-linux-gnueabihf/ doesn't work!

For my use, I would like Python to find GLESv2 library in /opt/vc/include...

Can someone explain what happens here?

Thanks!
My web site : https://codingfield.com

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Ctypes, doesn't load the good lib

Thu Jan 24, 2013 9:29 pm

The python.org documentation for ctypes says:
On Linux, find_library() tries to run external programs (/sbin/ldconfig, gcc, and objdump) to find the library file.
Which tells us we need to interrogate ldconfig:
ldconfig -p | grep GLES wrote: libGLESv2.so (libc6) => /opt/vc/lib/libGLESv2.so
So I don't have the problem that you do. However if your result is different, maybe reading the man page for ldconfig might give you a pointer.

JF002
Posts: 94
Joined: Sat Feb 04, 2012 8:49 am
Contact: Website

Re: Ctypes, doesn't load the good lib

Thu Jan 24, 2013 9:34 pm

Code: Select all

[email protected] ~ $ ldconfig -p | grep GLES
        libGLESv2.so.2 (libc6) => /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2
        libGLESv2.so (libc6) => /opt/vc/lib/libGLESv2.so
        libGLESv2.so (libc6) => /usr/lib/arm-linux-gnueabihf/libGLESv2.so
You're right! It founds 3 libGLESv2... Why? I don't know!
I'll read the man page.
My web site : https://codingfield.com

Return to “Python”