我的环境在MacOSX Catalina上使用Anaconda/Python 3.7.9
我已经为conda boost
安装了boost_python
#include <boost/python.hpp>
char const * doYouDo( const char* jobs ){
return "Hello, I am an embedded engineer.";
}
BOOST_PYTHON_MODULE( what ){
boost::python::def( "doYouDo", doYouDo);
}
然后用这个编译
g++ -fPIC -Wall -I/Users/whitebear/anaconda3/envs/aiwave/include/boost/python/ -I/Users/whitebear/anaconda3/envs/aiwave/include/python3.7m/ -lboost_python37 -shared -o whatModule.so what.cpp
我在下面得到了这个错误
In file included from what.cpp:1:
In file included from /usr/local/include/boost/python.hpp:28:
In file included from /usr/local/include/boost/python/exception_translator.hpp:10:
/usr/local/include/boost/bind.hpp:36:1: warning: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use
<boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior. [-W#pragma-messages]
BOOST_PRAGMA_MESSAGE(
^
/usr/local/include/boost/config/pragma_message.hpp:24:34: note: expanded from macro 'BOOST_PRAGMA_MESSAGE'
# define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x)))
^
<scratch space>:2:2: note: expanded from here
message("The practice of declaring the Bind placeholders (_1, _2, ...) " "in the global namespace is deprecated. Please use " "<boost/bind/bind.hpp> + using namespace bo...
^
1 warning generated.
Undefined symbols for architecture x86_64:
"_PyUnicode_Type", referenced from:
boost::python::to_python_value<char const* const&>::get_pytype() const in what-7927a1.o
"__Py_NoneStruct", referenced from:
boost::python::api::object::object() in what-7927a1.o
boost::python::converter::pointer_arg_from_python<char const*>::pointer_arg_from_python(_object*) in what-7927a1.o
boost::python::converter::pointer_arg_from_python<char const*>::operator()() const in what-7927a1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我猜它说没有_PyUnicode_Type
,__Py_NoneStruct
然而,哪个图书馆有它们??如有任何建议,我们将不胜感激
它是用
python-config ldflags
解决的下面是我最后的gcc命令
aiwave
是我的Python环境名称补充资料
我的python配置是2.7,但它不知怎么工作
相关问题 更多 >
编程相关推荐