In my application, I use boost_python and python 3.5.2. All built from source in Ubuntu 14.
When I built Python 3.5.2 from source with --with-shared
options in Ubuntu, I got libpython3.so
(7.6kB) and libpython3.5m.so
(12MB). I assume the big one is the real one and the small one might be something forwarding calls to the real interfaces.
As boost_python might assume the client to link against python (https://svn.boost.org/trac/boost/ticket/2615), I linked libpython3.so
with my application. But when I run it, I got the unresolved symbols error.
ldd -r myapp
or ldd -r libboost_python.so
both listed all python symbols unresolved which could be found in nm -D libpython3.5m.so
.
# ldd -r lib/libboost_python3.so
linux-vdso.so.1 => (0x00007ffe767fb000)
libstdc+.so.6 => /usr/lib/x86_64-linux-gnu/libstdc+.so.6 (0x00007f130a7a3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f130a58d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f130a1c8000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1309ec2000)
/lib64/ld-linux-x86-64.so.2 (0x00007f130acf4000)
undefined symbol: PyExc_ImportError (lib/libboost_python3.so)
undefined symbol: PyProperty_Type (lib/libboost_python3.so)
undefined symbol: PyExc_StopIteration (lib/libboost_python3.so)
undefined symbol: PyBool_Type (lib/libboost_python3.so)
undefined symbol: PyExc_ValueError (lib/libboost_python3.so)
undefined symbol: PyList_Type (lib/libboost_python3.so)
undefined symbol: _Py_NotImplementedStruct (lib/libboost_python3.so)
undefined symbol: PyExc_TypeError (lib/libboost_python3.so)
undefined symbol: PyDict_Type (lib/libboost_python3.so)
...
libpython3.so
depend on libpython3.5m.so
but itself has no those symbols.
I think based on that I should link my application with libpython3.5m.so
instead of with libpython3.so
. But the weird thing is that if I use LD_PRELOAD to load the libpython3.so, those symbols are found in ldd -r libboost_python3.so
# LD_LIBRARY_PATH=lib LD_PRELOAD=lib/libpython3.so ldd -r lib/libboost_python3.so
linux-vdso.so.1 => (0x00007ffcb51f0000)
lib/libpython3.so (0x00007f6f728e3000)
libstdc+.so.6 => /usr/lib/x86_64-linux-gnu/libstdc+.so.6 (0x00007f6f725df000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6f723c9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6f72004000)
libpython3.5m.so.1.0 => lib/libpython3.5m.so.1.0 (0x00007f6f71ae1000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6f718c3000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6f715bd000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6f72d32000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6f713b9000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f6f711b6000)
Why having the libpython3.so
and how to use it? Or shall I just only use the libpython3.5m.so
directly?
3.5m
is3.5
with different memory manager - you should have even programpython3.5m
. There was some information in Python doc but I don't remember where. – MastoPython 3.5.2
forUbuntu 14.04
- launchpad.net/~fkrull/+archive/ubuntu/deadsnakes – Mastopython3.5m.so
instead ofpython3.so
now. – Eritream
usepymalloc
instead ofmalloc
– Masto