[C++-sig] Problem with importing shared library into Python

Edgardo C. edxxgardo at gmail.com
Fri Nov 25 15:52:33 CET 2011


Hello Jim,

I really appreciate your feedback. I did what you mention, and I did it
downloading manually the boost library, compiling, etc, etc. Then, I
thought, ok, maybe I did something wrong and I downloaded the already
compiled boost packages using the synaptic tool in Ubuntu and then I
compiled the source code against the Ubuntu boost isntalled packages. The
compilation works fine, no errors but I get the same error.

What I do not know is whether the problem is the compilation of the shared
library or python. I spent the whole day on this,
agrrrrrrrrrrrrrrrrrrrrrrrrr

this guy :

http://www.mentby.com/vivek-60/


had a similar problem. But, this command:

$ nm /usr/local/lib/libboost_python3.so.1.46.1 | c++filt | grep init_module

show no symbols for me. Any other idea?



2011/11/25 Jim Bosch <talljimbo at gmail.com>

> On 11/25/2011 06:54 AM, Edgardo C. wrote:
>
>> Hello everybody,
>>
>> I am having problems with importing a .so shared library I just compiled
>> following the example giving in the book:
>> API Design for C++ : www.apibook.com <http://www.apibook.com> (Chapter
>> 11)
>>
>>
>> I downloaded the Boost library and I compiled it (fullw) into a
>> subdirectory called /compilation, where I get the /include and /lib
>> directories. No error during the compilation (Ubuntu 11.10).
>> Then I downloaded the code from the book examples and I compiled it
>> without errors and I get the phonebook.so in the same directory as where
>> I launch python interpreter, but the import in python trigger this error:
>>
>>
>> ImportError: /home/pablo/phonebook/**phonebook.so: undefined symbol:
>> _ZN5boost6python6detail11init_**moduleEPKcPFvvE
>>
>> what I think is because python does not find the library.
>>
>> I try to play around with the LD_LIBRARY_PATH variable, ldconfig, I
>> copied the phonebook.so library into /usr/lib and /usr/local/lib, and
>> nothing ... I get the same error.
>>
>> Can anybody explain me what is the problem? thanks a lot in advance,
>>
>>
> I think you just need to link your library against the boost_python
> library, and make sure that's also somewhere on your dynamic library path.
>  With gcc, that means adding a "-lboost_python" to the command line options.
>
> Jim
>
> ______________________________**_________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/**mailman/listinfo/cplusplus-sig<http://mail.python.org/mailman/listinfo/cplusplus-sig>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20111125/3ae9717f/attachment.html>


More information about the Cplusplus-sig mailing list