Boost/Python使用的未定义符号

2024-05-13 20:16:22 发布

您现在位置:Python中文网/ 问答频道 /正文

使用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

我在导入时得到以下错误:

^{pr2}$

这是什么意思,我该怎么解决?在


Tags: numpynormincludedefnpextractnamespaceint