我正在尝试使用以下命令编译并运行一个简单的hello world示例 在Mac上使用boost-python。这是我的设置以及遇到的问题。
我有一个包含以下文件的文件夹:
这里是他们的内容:
hello_ext.cpp
char const* greet()
{
return "hello, world";
}
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
hello_world.py
import atlas.examples.boost.hello_ext as hello_ext
print(hello_ext.greet())
Jamroot.jam
import python ;
project test
: requirements
<location>.
<include>/anaconda3/include/python3.6m
;
python-extension hello_ext : hello_ext.cpp ;
我的用户文件夹〜:中也有一个user-config.jam(由我创建和编辑)。
# g++ configuration
using darwin : : /usr/bin/g++
# Python configuration
using python : 3.6 : /anaconda3/bin/python3.6 ;
当我在项目文件夹中运行bjam时,我得到:
/usr/local/share/boost-build/src/build/feature.jam:277: in implied-feature from module feature
error: "/anaconda3/bin/python" is not an implicit feature value
/usr/local/share/boost-build/src/build/feature.jam:357: in expand-subfeatures-aux from module feature
/usr/local/share/boost-build/src/build/feature.jam:422: in feature.expand-subfeatures from module feature
/usr/local/share/boost-build/src/build/property.jam:212: in property.expand-subfeatures-in-conditions from module property
/usr/local/share/boost-build/src/build/toolset.jam:660: in toolset.add-requirements from module toolset
/usr/local/share/boost-build/src/tools/common.jam:245: in common.check-init-parameters from module common
/usr/local/share/boost-build/src/tools/darwin.jam:135: in darwin.init from module darwin
/usr/local/share/boost-build/src/build/toolset.jam:44: in toolset.using from module toolset
/usr/local/share/boost-build/src/build/project.jam:1052: in using from module project-rules
/Users/xxxxxxxx/user-config.jam:5: in modules.load from module user-config
/usr/local/share/boost-build/src/build-system.jam:255: in load-config from module build-system
/usr/local/share/boost-build/src/build-system.jam:453: in load-configuration-files from module build-system
/usr/local/share/boost-build/src/build-system.jam:607: in load from module build-system
/usr/local/share/boost-build/src/kernel/modules.jam:295: in import from module modules
/usr/local/share/boost-build/src/kernel/bootstrap.jam:139: in boost-build from module
/usr/local/share/boost-build/boost-build.jam:8: in module scope from module
事实上,我第一次使用这种配置运行bjam时,它会创建hello_ext.o和hello_ext.so。但是,当我尝试运行hello_world.py时,抛出了“找不到符号”错误,通常在编译/链接失败时会遇到。然后,我删除了这两个文件,bjam现在返回以上内容(即使我运行bjam --clean)。
有人有下一步尝试成功运行此程序的想法吗?