我正在尝试使用 libboost 库编译我的代码,方法是放入#include <boost/python.hpp>
我的 C++ 代码。有人可以帮我正确的命令来运行它,尤其是包含和链接库。我在这方面很基础。
使用的命令(但不工作):
g++ try.cpp -L /usr/lib/libboost_python.so -o try
编辑:
测试代码:
#include <boost/python.hpp>
#include <iostream>
int main()
{
std::cout << "Yes, it works :-)" << std::endl;
return 0;
}
错误信息:
from try.cpp:1:
/usr/include/boost/python/enum.hpp:31: error: expected ‘;’ before ‘*’ token
/usr/include/boost/python/enum.hpp:32: error: expected ‘;’ before ‘(’ token
/usr/include/boost/python/enum.hpp:33: error: ‘PyObject’ has not been declared
/usr/include/boost/python/enum.hpp:52: error: expected constructor, destructor, or type conversion before ‘*’ token
/usr/include/boost/python/enum.hpp:67: error: ‘void* boost::python::enum_<T>::convertible_from_python’ is not a static member of ‘struct boost::python::enum_<T>’
/usr/include/boost/python/enum.hpp:67: error: template definition of non-template ‘ void* boost::python::enum_<T>::convertible_from_python’
/usr/include/boost/python/enum.hpp:67: error: ‘PyObject’ was not declared in this scope
/usr/include/boost/python/enum.hpp:67: error: ‘obj’ was not declared in this scope
/usr/include/boost/python/enum.hpp:80: error: variable or field ‘construct’ declared void
/usr/include/boost/python/enum.hpp:80: error: ‘PyObject’ was not declared in this scope
/usr/include/boost/python/enum.hpp:80: error: ‘obj’ was not declared in this scope
/usr/include/boost/python/enum.hpp:80: error: expected primary-expression before ‘*’ token
/usr/include/boost/python/enum.hpp:80: error: ‘data’ was not declared in this scope
另一件事是,当我编译时g++ -Wall thread_one.cpp -o thread_one -lboost_thread
,它可以使用 boost_thread 库。