I am trying to install PyFTGL on MacOSX Yosemite.
The python version I am using is 2.7 from macports. I have installed boost from macports specifying +python27.
To install PyFTGL I built from source and edited the setup.py file from:
module_ftgl_libs = [
'GLU',
'GL',
'freetype',
'z',
'ftgl',
'boost_python',
]
module_ftgl = Extension(
'FTGL',
module_ftgl_src,
include_dirs=module_ftgl_include_dirs,
libraries=module_ftgl_libs
)
to:
module_ftgl_libs = [
'freetype',
'z',
'ftgl',
'boost_python',
]
module_ftgl = Extension(
'FTGL',
module_ftgl_src,
include_dirs=module_ftgl_include_dirs,
libraries=module_ftgl_libs,
extra_link_args=['-framework', 'OpenGL', '-framework', 'GLUT']
)
I then build the setup.py file and copy the resulting FTGL.so file to the same folder as my python code test.py which uses the FTGL functions.
My problem is when I now run my code I get the following error:
Traceback (most recent call last):
File "test.py", line 29, in <module>
import FTGL
ImportError: dlopen(/Users/james/Desktop/test/FTGL.so, 2): Symbol not found:__ZN5boost6python7objects15function_objectERKNS1_11py_functionERKNSt3__14pairIPNS0_6detail7keywordESA_EE
Referenced from: /Users/james/Desktop/test/FTGL.so
Expected in: flat namespace
in /Users/james/Desktop/test/FTGL.so
I don't know much about linking, setup.py files and boost and I have spent a long time researching on both Google and Stack Overflow but now I can't figure out the problem.
Using c++filt
, the symbol can be decoded as:
$ c++filt -n _ZN5boost6python7objects15function_objectERKNS1_11py_functionERKSt4pairIPKNS0_6detail7keywordES9_E
boost::python::objects::function_object(boost::python::objects::py_function const&, std::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&)
Since I have the same issue, I looked for similar symbols in the libboost_python.dylib:
$ nm -gU ~/Downloads/boost_1_60_0/bin.v2/libs/python/build/darwin-4.2.1/debug/libboost_python.dylib | grep function_object
0000000000027cd0 T __ZN5boost6python7objects15function_objectERKNS1_11py_functionE
0000000000027c20 T __ZN5boost6python7objects15function_objectERKNS1_11py_functionERKNSt3__14pairIPKNS0_6detail7keywordESA_EE
One of which decodes as:
boost::python::objects::function_object(boost::python::objects::py_function const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&)
The only difference is that the boost dynamic lib uses std::__1::pair
instead of std::pair
.
As also mentioned here: Why can't clang with libc++ in c++0x mode link this boost::program_options example?, libc++
and libstdc++
are not compatible. One option is to recompile boost with libstdc++
:
./b2 cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" python
I was able to overcome this error by uninstalling all boost libraries then using brew install boost155 --with-python --with-mpi --without-single
and switching from homebrew gcc/g++-5 to gcc/g++-4.9
go to brew edit boost155
and replace the layout from tagged
to system
if possible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With