【发布时间】:2017-07-05 16:43:17
【问题描述】:
使用 Boost 1.63.0,我编写了以下代码:
向量.cpp
/* Boost/Python headers */
#include<boost/python/module.hpp>
#include<boost/python/def.hpp>
#include<boost/python/extract.hpp>
#include<boost/python/numpy.hpp>
#include<cmath>
using namespace boost::python;
namespace np = boost::python::numpy;
double eucnorm(np::ndarray axis){
const int n = axis.shape(0);
double norm = 0.0;
for(int i = 0; i < n; i++){
double A = boost::python::extract<double>(axis[i]);
norm += A*A;
}
return sqrt(norm);
}
BOOST_PYTHON_MODULE(vectors){
def("eucnorm", eucnorm);
}
我使用以下代码编译了这个:g++ -shared -fpic -I /usr/include/python2.7 -I /foo/bar/boost_1_63_0 -lboost_python -o vectors.so
导入时出现以下错误:
from vectors import *
ImportError: ./vectors.so: undefined symbol: _ZN5boost6python9converter21object_manager_traitsINS0_5numpy7ndarrayEE10get_pytypeEv
这是什么意思,我该如何解决?
【问题讨论】: