使用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
我在导入时得到以下错误:
这是什么意思,我该怎么解决?在
添加:
当你建造。所以。在
顺便说一句,如果您想在构建时发现此类问题(而不是在Python中尝试
import
):Force GCC to notify about undefined references in shared libraries相关问题 更多 >
编程相关推荐