【发布时间】:2016-08-10 07:01:30
【问题描述】:
我在装有 OS X 10.11.6 的 Mac 上使用 homebrew 安装了 boost 以及 boost-python 和 boost-build。我正在运行 Python 3.5.2。 boost 已正确设置并适用于 C++ 项目。 user-config.jam 和我的 python 扩展项目目录中的 jamfile 都可以。我试图从以下来源编译一个共享库
#include <iostream>
#include <boost/python.hpp>
using namespace std;
void say_hello() {
std::cout << "HELLO!!!!!";
}
BOOST_PYTHON_MODULE(hello) {
using namespace boost::python;
def ("say_hello", say_hello);
}
使用b2 解释器。它发出以下命令:
"g++" -dynamiclib -Wl,-single_module -install_name "hello.so" -L"/usr/local/lib/python3.5" -o "bin/darwin-4.2.1/release/hello.so" "bin/darwin-4.2.1/release/say_hello.o" -lpython3.5 -headerpad_max_install_names -Wl,-dead_strip -no_dead_strip_inits_and_terms
,与
一起崩溃darwin.link.dll bin/darwin-4.2.1/release/hello.so
架构 x86_64 的未定义符号:
“boost::python::objects::py_function_impl_base 的类型信息”,引用自:
[...长追溯...]
“boost::python::detail::init_module(PyModuleDef&, void (*)())”,引用自:
say_hello.old 中的_PyInit_hello:未找到架构 x86_64 的符号
我非常了解有关类似问题的所有问题,但不幸的是,它们都没有提供有效的答案。
我需要做什么才能让这个简单的代码作为 Python 扩展模块工作?
【问题讨论】:
标签: c++ python-3.5 boost-python