[C++-sig] Boost-Python Linking Problem with Hello World Example

Anders Wallin anders.e.e.wallin at gmail.com
Thu Dec 20 06:58:27 CET 2012


It's hard to get the includes/libs right by hand on the command line.
Better to use a build-tool like bjam, cmake, or something.
Can you try this cmake build:
https://github.com/aewallin/sandbox/tree/master/boost_python_helloworld
cmake .
and then
make

if you want to see the actual command-line cmake produces I think you can
see it with make VERBOSE=1.

Ubuntu 12.10 has boost 1.49.0 by default, so it looks like you are using a
DIY-build of boost? That may be the cause also.

Anders



On Thu, Dec 20, 2012 at 6:47 AM, Hesam <hesam.ilati2 at gmail.com> wrote:

> Hello,
>
> I am trying to compile and link boost-python hello world example and I
> have some linking problems.
>
> OS: Ubuntu
>
> g++ -fPIC -w Test2.cpp -I ../../../Libs/Python/Python-2.7.3/Include -I ../../../Libs/Python/Python-2.7.3 -I ../../../Libs/Boost/boost_1_52_0 -Wl,-rpath,../../../Libs/Python/Python-2.7.3/build/lib.linux-x86_64-2.7 -L -L../../../Libs/Python/Python-2.7.3/build/lib.linux-x86_64-2.7 -lssl -lcrypto -lpthread -lm -lutil -lpython2.7 -Wl,-rpath, -L../../../Libs/Boost/boost_1_52_0/lib -L../../../Libs/Boost/boost_1_52_0/stage/lib -lboost_python
>
> I get the following *Error*
>
> ../../../Libs/Boost/boost_1_52_0/stage/lib/libboost_python.so: undefined reference to `PyUnicodeUCS2_AsWideChar'
> ../../../Libs/Boost/boost_1_52_0/stage/lib/libboost_python.so: undefined reference to `PyUnicodeUCS2_FromEncodedObject'
> collect2: ld returned 1 exit status
> make: *** [Test2] Error 1
>
> I heard that it maybe due to incompatible version of python and the python
> library used by Boost-python. But whatever I tried I couldn't solve the
> problem. It is taking several days and no success. Appreciate any comment.
>
> Thanks
>
> Hesam
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121220/a0f6afa9/attachment-0001.html>


More information about the Cplusplus-sig mailing list