Question: "load"ing a shared object in python

P

Pro Grammer

Hello, all,
I am not sure if this is the right place to ask, but could you kindly
tell me how to "load" a shared object (like libx.so) into python, so
that the methods in the .so can be used? That too, given that the shared
object was written in c++, compiled with g++ ?
Thanks,
Pro Grammer
 
R

Rick L. Ratzel

Pro Grammer said:
Hello, all,
I am not sure if this is the right place to ask, but could you kindly tell me
how to "load" a shared object (like libx.so) into python, so that the methods in
the .so can be used? That too, given that the shared object was written in c++,
compiled with g++ ?
Thanks,
Pro Grammer

Will the dl standard library module help you? From the Python docs at:

http://docs.python.org/lib/module-dl.html

Example:
(929723914, 929723914.498)

I'm guessing that there might be some C++ issues, but maybe it's worth
looking into.

Rick
 
M

Mark Rowe

Will the dl standard library module help you? From the Python docs
at:

http://docs.python.org/lib/module-dl.html

As Simon Brunning notes, ctypes
Example:

(929723914, 929723914.498)

A note about this example: the `dl' call returns an integer as that is
what the C time function returns. time.time() in Python is implemented
in terms of C's gettimeofday, ftime or time depending on the platform.
I'm guessing that there might be some C++ issues, but maybe it's worth
looking into.

As far as I am aware, neither dl nor ctypes natively support C++. This
is a tricky matter, due to the lack of standards for C++ ABI's covering
name mangling and vtable layout etc. See the thread starting at
<http://mail.python.org/pipermail/python-list/2004-November/
249513.html> for more information.

Regards,

Mark Rowe
<http://bdash.net.nz/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top