|
Boost-Build : |
Subject: [Boost-build] Python Static Lib compilation and linking on MacosX
From: Siegfried Hand (siegfried.hand_at_[hidden])
Date: 2011-01-29 05:21:36
Hi all.
I'm trying to make python linking with my project since 3 days now.
After trying everything i can found, i still have no joy.
I hope someone could help me.
First i' have downloaded Boot 1.45.0.
Installed Python 3.1 on my MacOsX (10.6.6)
I have edited the project-config.jam, where i include the following :
"using python
: 3.1 # version
: /Library/Frameworks/Python.framework/Versions/3.1/bin/python3.1
#cmd-or-prefix
: /Library/Frameworks/Python.framework/Versions/3.1/include/python3.1
# includes
: /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1
# libraries
: # condition
: # extension-suffix
;"
then i build the Boost python with this command line :
"./bjam toolset=darwin architecture=x86 link=static threading=multi
runtime-link=static --debug-configuration target-os=darwin
macosx-version=10.5 macosx-version-min=10.5"
The output let me guess that it compile the correct version, with the
correct lib & framework :
"notice: Loading project-config configuration file project-config.jam
from project-config.jam .
notice: OSX version on this machine is 10.6.6
notice: will use 'g++' for darwin, condition <toolset>darwin-4.2.1
notice: using strip for <toolset>darwin-4.2.1 at /usr/bin/strip
notice: using archiver for <toolset>darwin-4.2.1 at /usr/bin/libtool
notice: available sdk for <toolset>darwin-4.2.1/<macosx-version>10.5
at /Developer/SDKs/MacOSX10.5.sdk
notice: available sdk for <toolset>darwin-4.2.1/<macosx-version>10.6
at /Developer/SDKs/MacOSX10.6.sdk
notice: [python-cfg] Configuring python...
notice: [python-cfg] user-specified version: "3.1"
notice: [python-cfg] user-specified cmd-or-prefix:
"/Library/Frameworks/Python.framework/Versions/3.1/bin/python3.1"
notice: [python-cfg] user-specified includes:
"/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1"
notice: [python-cfg] user-specified libraries:
"/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1"
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg] interpreter command:
"/Library/Frameworks/Python.framework/Versions/3.1/bin/python3.1"
notice: [python-cfg] include path:
"/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1"
notice: [python-cfg] library path:
"/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1"
notice: [python-cfg] framework directory is
"/Library/Frameworks/Python.framework"
notice: [cmdline-cfg] Detected command-line request for darwin:
toolset= darwin version=
notice: [cmdline-cfg] toolset darwin already configured
notice: iostreams: using prebuilt zlib
notice: iostreams: using prebuilt bzip2"
First point here, bjam generate two static libs. One called
libboost_python.a and the other libboost_python3.a. I wonder why ?
Using a diff viewer show me that those files are exactly the same.
The XCode (3.2.5) part now.
In my project i include the "libboost_python3.a" lib then i add the
python framework (which point to
"library/Frameworks/Python.framework", the version inside this
location is 3.1).
After compiling (debug) my project the linker failed with :
"Undefined symbols:
"_PyModule_Create2", referenced from:
boost::python::detail::init_module(char const*, void (*)())in
libFluxCore.a(module.o)
"_PyBytes_Size", referenced from:
boost::python::converter::(anonymous
namespace)::slot_rvalue_from_python<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
boost::python::converter::(anonymous
namespace)::string_rvalue_from_python>::construct(_object*,
boost::python::converter::rvalue_from_python_stage1_data*)in
libFluxCore.a(builtin_converters.o)
"_PyUnicode_InternFromString", referenced from:
_function_get_name in libFluxCore.a(function.o)
"__PyUnicode_AsString", referenced from:
boost::python::converter::(anonymous
namespace)::convert_to_cstring(_object*)in
libFluxCore.a(builtin_converters.o)
"_PyUnicodeUCS2_FromString", referenced from:
boost::python::detail::str_base::str_base(char const*)in
libFluxCore.a(str.o)
boost::python::detail::str_base::str_base()in libFluxCore.a(str.o)
boost::python::detail::str_base::str_base(char const*)in
libFluxCore.a(str.o)
boost::python::detail::str_base::str_base()in libFluxCore.a(str.o)
boost::python::converter::do_return_to_python(char const*)in
libFluxCore.a(builtin_converters.o)
"_PyUnicodeUCS2_FromStringAndSize", referenced from:
boost::python::detail::str_base::str_base(char const*, unsigned
long)in libFluxCore.a(str.o)
boost::python::detail::str_base::str_base(char const*, char
const*)in libFluxCore.a(str.o)
boost::python::detail::str_base::str_base(char const*, char
const*)in libFluxCore.a(str.o)
boost::python::detail::str_base::str_base(char const*, unsigned
long)in libFluxCore.a(str.o)
boost::python::converter::do_return_to_python(char)in
libFluxCore.a(builtin_converters.o)
_object* boost::python::api::object_base_initializer<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
>(std::basic_string<char, std::char_traits<char>, std::allocator<char>
> const&)in libFluxCore.a(function_doc_signature.o)
"_PyLong_AsSsize_t", referenced from:
boost::python::detail::list_base::insert(boost::python::api::object
const&, boost::python::api::object const&)in libFluxCore.a(list.o)
boost::python::detail::list_base::index(boost::python::api::object
const&) constin libFluxCore.a(list.o)
boost::python::detail::list_base::count(boost::python::api::object
const&) constin libFluxCore.a(list.o)
_instance_new in libFluxCore.a(class.o)
"_PyUnicodeUCS2_FromFormat", referenced from:
boost::python::converter::rvalue_from_python_stage2(_object*,
boost::python::converter::rvalue_from_python_stage1_data&,
boost::python::converter::registration const&)in
libFluxCore.a(from_python.o)
boost::python::converter::(anonymous
namespace)::throw_no_lvalue_from_python(_object*,
boost::python::converter::registration const&, char const*)in
libFluxCore.a(from_python.o)
boost::python::converter::(anonymous
namespace)::lvalue_result_from_python(_object*,
boost::python::converter::registration const&, char const*)in
libFluxCore.a(from_python.o)
boost::python::converter::registration::to_python(void const
volatile*) constin libFluxCore.a(registry.o)
"_PyBytes_AsString", referenced from:
boost::python::converter::(anonymous
namespace)::slot_rvalue_from_python<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
boost::python::converter::(anonymous
namespace)::string_rvalue_from_python>::construct(_object*,
boost::python::converter::rvalue_from_python_stage1_data*)in
libFluxCore.a(builtin_converters.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status"
Looking in source file where the linker failed i always find "#if
PY_VERSION_HEX >= 0x03000000" which let me guess that the python
version is wrong... (< 3.0)
So i finally us "nm" to find those symbols in the "libboost_python3.a"
lib, it say that those function are undefined.
Well, i hope someone could help me to turn the light on.
Thanks.
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk