简体   繁体   English

MacOSX + Boost_Python + PyFTGL: - 未找到符号,预期在:flat namespace

[英]MacOSX + Boost_Python + PyFTGL :- Symbol not found, expected in: flat namespace

I am trying to install PyFTGL on MacOSX Yosemite. 我正在尝试在MacOSX Yosemite上安装PyFTGL。

The python version I am using is 2.7 from macports. 我使用的python版本是来自macports的2.7。 I have installed boost from macports specifying +python27. 我从macports安装了boost + python27。

To install PyFTGL I built from source and edited the setup.py file from: 要安装从源代码构建的PyFTGL,并从以下位置编辑setup.py文件:

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. 然后我构建setup.py文件并将生成的FTGL.so文件复制到与使用FTGL函数的python代码test.py相同的文件夹中。

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. 我不太了解链接,setup.py文件和提升,我花了很长时间研究Google和Stack Overflow,但现在我无法弄清楚问题。

Using c++filt , the symbol can be decoded as: 使用c++filt ,符号可以解码为:

$ 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: 由于我有同样的问题,我在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 . 唯一的区别是boost动态lib使用std::__1::pair而不是std::pair

As also mentioned here: Why can't clang with libc++ in c++0x mode link this boost::program_options example? 正如这里也提到的: 为什么不能用c ++ 0x模式中的libc ++来链接这个boost :: program_options例子? , libc++ and libstdc++ are not compatible. libc++libstdc++不兼容。 One option is to recompile boost with libstdc++ : 一种选择是使用libstdc++重新编译boost:

./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 通过卸载所有boost库然后使用brew install boost155 --with-python --with-mpi --without-single并从homebrew gcc / g ++ - 5切换到gcc / g ++ - 4.9,我能够克服这个错误

go to brew edit boost155 and replace the layout from tagged to system if possible 如果可能的话,去brew edit boost155并将taggedtagged替换为system

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM