我从ubuntu 9.04存储库安装了boost python.我从教程中成功运行 了使用Boost构建一个简单程序,所以我知道我的系统上安装了boost python.
但是,以下程序会返回错误:
#include <string>
namespace { // Avoid cluttering the global namespace.
// A couple of simple C++ functions that we want to expose to Python.
std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }
}
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(getting_started1)
{
// Add regular functions to the module.
def("greet", greet);
def("square", square);
}
Run Code Online (Sandbox Code Playgroud)
我尝试从以下两个步骤执行第一步来创建共享库:
g++ -c -fPIC hello.cpp -o hello.o
g++ -shared -Wl,-soname,libhello.so -o libhello.so hello.o …Run Code Online (Sandbox Code Playgroud)