Opened 12 years ago

Last modified 12 years ago

#5263 new Bugs

Undefined symbols in libboost_python

Reported by: mschu.dev+boost@… Owned by: Dave Abrahams
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost 1.46.0 Severity: Problem
Keywords: python undefined symbols Cc:

Description

When building and running pythonmagick (imagemagick python bindings dependent on boost), importing python-boost libraries fails with the following error:

ImportError: /usr/lib/libboost_python.so.1.46.0: undefined symbol: PyClass_Type

This happens although boost was compiled with python3 support and pythonmagick was linked to libboost_python and all python3 libraries in python-config --libs.

Checking libboost_python with ldd yields a whole list of undefined symbols [1].

This was originally filed as a bugreport for the ArchLinux distribution but the maintainer suggested an upstream problem [2].

[1] ldd -r /usr/lib/libboost_python.so.1.46.0 ; output: see [2] [2] https://bugs.archlinux.org/task/23130

Change History (4)

comment:1 by biru.ionut@…, 12 years ago

our boost package now is built with python 2.7 and python 3.2 support but this issue was there in the previous version which had only python 2.7 support.

the default compilation cflags/ldflags are:

CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed

at first i was thinking this issue was because of --as-needed but the issue persist.

user-config.jam has this additionaly lines

using python : 2.7 : /usr/bin/python2 ;
using python : 3.2 : /usr/bin/python : /usr/include/python3.2mu : /usr/lib ;
using mpi ;

and bjam options are:

release debug-symbols=off threading=multi \
      runtime-link=shared link=shared,static \
      cflags=-fno-strict-aliasing \
      toolset=gcc \
      --prefix="${_stagedir}" \
      -sTOOLS=gcc \
      --layout=system
 install

comment:2 by Dave Abrahams, 12 years ago

Can you reproduce this problem with a minimal project when following the instructions here: http://www.boost.org/doc/libs/1_46_0/libs/python/doc/building.html ?

comment:3 by anonymous, 12 years ago

Using python3.2 includes and interpreter:

mschu@xps:~/Downloads/boost_1_46_1/libs/python/example/quickstart$ bjam toolset=gcc --verbose-test test
...patience...
...patience...
...found 1535 targets...
...updating 9 targets...
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/builtin_converters.o
../../../../libs/python/src/converter/builtin_converters.cpp: In static member function »static std::wstring boost::python::converter::<unnamed>::wstring_rvalue_from_python::extract(PyObject*)«:
../../../../libs/python/src/converter/builtin_converters.cpp:436:32: Fehler: »PyUnicodeObject*« kann nicht nach »PyObject*« für Argument »1« nach »Py_ssize_t PyUnicodeUCS4_AsWideChar(PyObject*, wchar_t*, Py_ssize_t)« umgewandelt werden

    "g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC  -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE  -I"../../../.." -I"/usr/include/python3.2" -c -o "../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/builtin_converters.o" "../../../../libs/python/src/converter/builtin_converters.cpp"

...failed gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/builtin_converters.o...
...skipped <p../../../../bin.v2/libs/python/build/gcc-4.5.2/debug>libboost_python.so.1.46.1 for lack of <p../../../../bin.v2/libs/python/build/gcc-4.5.2/debug>converter/builtin_converters.o...
...skipped <pbin/gcc-4.5.2/debug>extending.so for lack of <p../../../../bin.v2/libs/python/build/gcc-4.5.2/debug>libboost_python.so.1.46.1...
...skipped <pbin/test_ext.test/gcc-4.5.2/debug>test_ext for lack of <pbin/gcc-4.5.2/debug>extending.so...
gcc.compile.c++ bin/gcc-4.5.2/debug/embedding.o
embedding.cpp: In Funktion »void exec_test()«:
embedding.cpp:56:48: Fehler: »initembedded_hello« wurde in diesem Gültigkeitsbereich nicht definiert

    "g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC    -I"../../../.." -I"/usr/include/python3.2" -c -o "bin/gcc-4.5.2/debug/embedding.o" "embedding.cpp"

...failed gcc.compile.c++ bin/gcc-4.5.2/debug/embedding.o...
...skipped <pbin/gcc-4.5.2/debug>embedding for lack of <pbin/gcc-4.5.2/debug>embedding.o...
...skipped <pbin/test_embed.test/gcc-4.5.2/debug>test_embed.run for lack of <pbin/gcc-4.5.2/debug>embedding...
...failed updating 2 targets...
...skipped 7 targets...

I wanted to try 2.7 as well, but I don't know how to tell bjam to use 'python2' instead of 'python'.

comment:4 by anonymous, 12 years ago

Here is the full output with the 2 lines added to user-config.jam as Biru did. Tests seem to work.

...patience...
...patience...
...found 1607 targets...
...updating 54 targets...
common.mkdir bin
common.mkdir bin/test_ext.test
common.mkdir bin/test_ext.test/gcc-4.5.2
common.mkdir bin/test_ext.test/gcc-4.5.2/debug
common.mkdir bin/gcc-4.5.2
common.mkdir bin/gcc-4.5.2/debug
gcc.compile.c++ bin/gcc-4.5.2/debug/extending.o
common.mkdir ../../../../bin.v2
common.mkdir ../../../../bin.v2/libs
common.mkdir ../../../../bin.v2/libs/python
common.mkdir ../../../../bin.v2/libs/python/build
common.mkdir ../../../../bin.v2/libs/python/build/gcc-4.5.2
common.mkdir ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/numeric.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/list.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/long.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/dict.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/tuple.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/str.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/slice.o
common.mkdir ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/from_python.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/registry.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/type_id.o
common.mkdir ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/enum.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/class.o
../../../../libs/python/src/object/class.cpp: In Funktion »int boost::python::property_init(PyObject*, PyObject*, PyObject*)«:
../../../../libs/python/src/object/class.cpp:79:64: Warnung: veraltete Konvertierung von Zeichenkettenkonstante in »char*«
../../../../libs/python/src/object/class.cpp:79:64: Warnung: veraltete Konvertierung von Zeichenkettenkonstante in »char*«
../../../../libs/python/src/object/class.cpp:79:64: Warnung: veraltete Konvertierung von Zeichenkettenkonstante in »char*«
../../../../libs/python/src/object/class.cpp:79:64: Warnung: veraltete Konvertierung von Zeichenkettenkonstante in »char*«
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/function.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/inheritance.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/life_support.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/pickle_support.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/errors.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/module.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/builtin_converters.o
../../../../libs/python/src/converter/builtin_converters.cpp:369:13: Warnung: »boost::python::converter::<unnamed>::py_unicode_as_string_unaryfunc« definiert, aber nicht verwendet
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/converter/arg_to_python_base.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/iterator.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/stl_iterator.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object_protocol.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object_operators.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/wrapper.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/import.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/exec.o
gcc.compile.c++ ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/object/function_doc_signature.o
gcc.link.dll ../../../../bin.v2/libs/python/build/gcc-4.5.2/debug/libboost_python.so.1.46.1
gcc.link.dll bin/gcc-4.5.2/debug/extending.so
capture-output bin/test_ext.test/gcc-4.5.2/debug/test_ext
====== BEGIN OUTPUT ======
[?1034hTrying:
    from extending import *
Expecting nothing
ok
Trying:
    hi = hello('California')
Expecting nothing
ok
Trying:
    hi.greet()
Expecting:
    'Hello from California'
ok
Trying:
    invite(hi)
Expecting:
    'Hello from California! Please come soon!'
ok
Trying:
    hi.invite()
Expecting:
    'Hello from California! Please come soon!'
ok
Trying:
    class wordy(hello):
        def greet(self):
            return hello.greet(self) + ', where the weather is fine'
Expecting nothing
ok
Trying:
    hi2 = wordy('Florida')
Expecting nothing
ok
Trying:
    hi2.greet()
Expecting:
    'Hello from Florida, where the weather is fine'
ok
Trying:
    invite(hi2)
Expecting:
    'Hello from Florida! Please come soon!'
ok
1 items had no tests:
    test_extending.run
1 items passed all tests:
   9 tests in test_extending
9 tests in 2 items.
9 passed and 0 failed.
Test passed.

EXIT STATUS: 0
====== END OUTPUT ======
**passed** bin/test_ext.test/gcc-4.5.2/debug/test_ext.test
common.mkdir bin/test_embed.test
common.mkdir bin/test_embed.test/gcc-4.5.2
common.mkdir bin/test_embed.test/gcc-4.5.2/debug
gcc.compile.c++ bin/gcc-4.5.2/debug/embedding.o
gcc.link bin/gcc-4.5.2/debug/embedding
testing.capture-output bin/test_embed.test/gcc-4.5.2/debug/test_embed.run
====== BEGIN OUTPUT ======
registering extension module embedded_hello...
defining Python class derived from Base...
testing derived class from C++...
success!
running file script.py...
Hello World !
success!
intentionally causing a python exception...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'unknown' is not defined
No errors detected.

EXIT STATUS: 0
====== END OUTPUT ======
**passed** bin/test_embed.test/gcc-4.5.2/debug/test_embed.test
...updated 54 targets...

Note: See TracTickets for help on using tickets.