[C++-sig] importing issues with c++ shared dynamic libraries (.so)

Tim Spens t_spens at yahoo.com
Fri Jul 13 20:08:11 CEST 2007


Thanks for the help you got me on the right path, when
I was using the linker to create my lib I didn't know
I needed to include all the dependent libraries in the
command.

ld -Bshareable -o libzee.so *.o -lX -lShared
-lboost_python -lboost_serialization -lboost_thread
-lxml2

--- Tim Spens <t_spens at yahoo.com> wrote:

> I have listed the paths to the other libraries in
> LD_LIBRARY_PATH but still have the same problem.
> 
> --- David A Wagner <David.A.Wagner at jpl.nasa.gov>
> wrote:
> 
> > Most likely, the dynamic loader is just failing to
> > find the dependent 
> > .so files because it doesn't
> > know where to look for them.  You have to list the
> > search paths in 
> > LD_LIBRARY_PATH
> > (inferring you're using linux) environment
> variable.
> > 
> > More info:  man ld.so
> > 
> > 
> > Tim Spens wrote:
> > > --- Tim Spens <t_spens at yahoo.com> wrote:
> > >
> > >   
> > >> I'm trying to import multiple c++ shared
> dynamic
> > >> libraries (.so) with inter-dependencies into
> > python.
> > >>
> > >> Then use one of the .so libraries which I've
> > added
> > >> boost.python wrappers to.  Here's the out put
> > from
> > >> python...
> > >>
> > >> using boost 1.33
> > >>
> > >> Python 2.5.1 (r251:54863, May  2 2007,
> 16:56:35) 
> > >> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> > >> Type "help", "copyright", "credits" or
> "license"
> > for
> > >> more information.
> > >>     
> > >>>>> import libxml2
> > >>>>> #libxml2.so imported just fine
> > >>>>>
> > >>>>> import libboost_thread
> > >>>>>           
> > >> Traceback (most recent call last):
> > >>   File "<stdin>", line 1, in <module>
> > >> ImportError: dynamic module does not define
> init
> > >> function (initlibboost_thread)
> > >>     
> > >>>>> import libboost_serialization
> > >>>>>           
> > >> Traceback (most recent call last):
> > >>   File "<stdin>", line 1, in <module>
> > >> ImportError: dynamic module does not define
> init
> > >> function (initlibboost_serialization)
> > >>     
> > >>>>> import libboost_python
> > >>>>>           
> > >> Traceback (most recent call last):
> > >>   File "<stdin>", line 1, in <module>
> > >> ImportError: dynamic module does not define
> init
> > >> function (initlibboost_python)
> > >>     
> > >>>>> import libX
> > >>>>>           
> > >> Traceback (most recent call last):
> > >>   File "<stdin>", line 1, in <module>
> > >> ImportError: dynamic module does not define
> init
> > >> function (initlibX)
> > >>     
> > >>>>> libX.so is a c++ dynamic shared library with
> > no
> > >>>>>           
> > >> boost.python wrappers
> > >>     
> > >>>>> import libShared
> > >>>>>           
> > >> Traceback (most recent call last):
> > >>   File "<stdin>", line 1, in <module>
> > >> ImportError: libShared.so: undefined symbol:
> > xmlFree
> > >>     
> > >>>>> libShared.so is a c++ dynamic shared library
> > >>>>>           
> > >> with
> > >> no boost.python wrappers
> > >>     
> > >>>>> import libzee
> > >>>>>           
> > >> Traceback (most recent call last):
> > >>   File "<stdin>", line 1, in <module>
> > >> ImportError: ./libzee.so: undefined symbol:
> > >> _ZTIN5boost10lock_errorE
> > >>     
> > >>>>> libzee.so is a c++ dynamic shared library
> with
> > >>>>>           
> > >> boost.python wrappers added
> > >>
> > >> I've tried using ld.open but it seems to only
> > allow
> > >> me
> > >> to call specific functions in the libraries and
> > >> doesn't allow the libraries to talk to each
> > other.
> > >>
> > >> Any help will be greatly appreciated.
> > >>
> > >>
> > >>     
> > >
> > > I've just learned that I need to only import my
> > > wrapped library, and python should find the
> > libraries
> > > the wrapped lib is dependent upon when it's
> > loaded? 
> > > So I added the paths of my c++ libraries and
> boost
> > > libs to the sys.path and env path, but I still
> > have
> > > the same problem importing my python wrapped c++
> > lib
> > > because it has dependencies on boost libs.
> > >
> > >   
> > >>>> import libzee
> > >>>>         
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > > ImportError: ./libzee.so: undefined symbol:
> > > _ZTIN5boost10lock_errorE
> > >
> > >
> > > _______________________________________________
> > > C++-sig mailing list
> > > C++-sig at python.org
> > > http://mail.python.org/mailman/listinfo/c++-sig
> > >
> > >   
> > > begin:vcard
> > fn:David Wagner
> > n:Wagner;David
> > org:Caltech/Jet Propulsion Laboratory;Flight
> > Software Applications Group
> > adr;dom:;;4800 Oak Grove Drive;Pasadena;CA;91109
> > email;internet:David.A.Wagner at jpl.nasa.gov
> > title:Senior Software Engineer
> > tel;work:818 354 1148
> > x-mozilla-html:TRUE
> > version:2.1
> > end:vcard
> > 
> > > _______________________________________________
> > C++-sig mailing list
> > C++-sig at python.org
> > http://mail.python.org/mailman/listinfo/c++-sig
> > 
> 
> 
> 
>        
>
____________________________________________________________________________________
> Building a website is a piece of cake. Yahoo! Small
> Business gives you all the tools to get online.
> http://smallbusiness.yahoo.com/webhosting 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 



       
____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php



More information about the Cplusplus-sig mailing list