469,951 Members | 2,705 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,951 developers. It's quick & easy.

Problem Dynamic Loading Linux C++ .so module using python2.4

I have compiled my boost-enabled C++ module and have it working when I
explicity set my LD_LIBRARY_PATH before invoking the python2.4
interpreter. Now I don't want everyone to have to set this environment
variable so I would like to devise a way that the module can load
itself. My attempt was to create a module folder with the following
__init__.py:

-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
import os
import sys

my_path = os.path.dirname(os.path.abspath(__file__))
mylib_path = os.path.join(my_path, 'subdirOfSitePackages')

if sys.platform == 'win32':
# Windows needs DLLs on the %PATH%.
os.environ['PATH'] = os.environ['PATH'] + ";" + my_path
else:
# LINUX
if os.environ.has_key('LD_LIBRARY_PATH'):
os.environ['LD_LIBRARY_PATH'] = mylib_path + ":" +
os.environ['LD_LIBRARY_PATH']
else:
os.environ['LD_LIBRARY_PATH'] = mylib_path

from myLibFolder._mylib import *

-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

On my filesystem I have the following folder:

/usr/lib/python2.4/site-packages/myLibFolder

With the following files:
__init__.py
_mylib.so
mylibDBAccess.so
mylibCommon.so
libboost_python.so

Where _mylib.so dynamically links with mylibDBAccess.so,
mylibCommon.so, libboost_python.so.

When I try to import this Folder in python2.4, it actually complains
about the subsequent dynamic linking of the .so files (ie
mylibDBAccess.so).

Any ideas on how to resolve this?

Regards,
Liam

Apr 10 '06 #1
1 1786
On 10 Apr 2006 12:42:28 -0700, liam_herron <li*********@hotmail.com> wrote:
I have compiled my boost-enabled C++ module and have it working when I
explicity set my LD_LIBRARY_PATH before invoking the python2.4
interpreter. Now I don't want everyone to have to set this environment
variable so I would like to devise a way that the module can load
itself. My attempt was to create a module folder with the following
__init__.py:

-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
import os
import sys

my_path = os.path.dirname(os.path.abspath(__file__))
mylib_path = os.path.join(my_path, 'subdirOfSitePackages')

if sys.platform == 'win32':
# Windows needs DLLs on the %PATH%.
os.environ['PATH'] = os.environ['PATH'] + ";" + my_path
else:
# LINUX
if os.environ.has_key('LD_LIBRARY_PATH'):
os.environ['LD_LIBRARY_PATH'] = mylib_path + ":" +
os.environ['LD_LIBRARY_PATH']
else:
os.environ['LD_LIBRARY_PATH'] = mylib_path

from myLibFolder._mylib import *

-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

On my filesystem I have the following folder:

/usr/lib/python2.4/site-packages/myLibFolder

With the following files:
__init__.py
_mylib.so
mylibDBAccess.so
mylibCommon.so
libboost_python.so

Where _mylib.so dynamically links with mylibDBAccess.so,
mylibCommon.so, libboost_python.so.

When I try to import this Folder in python2.4, it actually complains
about the subsequent dynamic linking of the .so files (ie
mylibDBAccess.so).

Any ideas on how to resolve this?
I think you can not. I can not find the article, but I read that changes of
LD_LIBRARY_PATH after program start, does not have any effects, because this
variable is read only once - at program launching.

I think small shell script will help you.
Regards,
Liam

--
http://mail.python.org/mailman/listinfo/python-list

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
Apr 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jose Vicente Nunez Z | last post: by
2 posts views Thread by baileyxia | last post: by
2 posts views Thread by dwelch91 | last post: by
1 post views Thread by aznach | last post: by
reply views Thread by Neal Becker | last post: by
4 posts views Thread by Tommy Grav | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.