在我的c++代码中包含boost有问题,该代码是使用'swig‘编写的。我想把c++作为我的python的后端。
调用这两个命令
swig -c++ -python spherical_overlap.i
python setup.py build_ext --inplace后者给出了以下错误
clang: warning: -lboost_system : 'linker' input unused
In file included from spherical_overlap_wrap.cxx:3427:
./spherical_overlap.h:8:10: fatal error: 'boost/math/special_functions/bessel.hpp' file not found
#include <boost/math/special_functions/bessel.hpp>文件就在那里。我认为我必须为编译器设置以下标志
-I /usr/local/include问题是,我不知道怎么做。这是我的“setup.py”文件
#!/usr/bin/env python
from distutils.core import setup, Extension
spherical_overlap_module = Extension('_spherical_overlap',
                           sources=['spherical_overlap_wrap.cxx', 'spherical_overlap.cpp'],
                           swig_opts=['-c++', '-py3'],
                           extra_compile_args =['-lboost_system '],
                           )
setup (name = 'spherical_overlap',
       version = '0.1',
       author      = "SWIG Docs",
       description = """Simple swig spherical_overlap from docs""",
       ext_modules = [spherical_overlap_module],
       py_modules = ["spherical_overlap"],
       )发布于 2015-10-26 15:01:15
您可以执行以下任一操作:
include_dirs = ['/usr/local/include'],添加到Extension构造函数调用中setup.cfgbuild_ext include-dirs =/usr/build_ext/build_ext文件中include-dirs命令指定build_ext选项,即运行
python setup.py build_ext --inplace --包括-dirs/usr/local/build_ext-I/usr/local/include添加到CPPFLAGS环境变量,例如,运行
CPPFLAGS=“-i/usr/local/包括”python setup.py build_ext -inplace“第二种可能是首选的方法,因为它反映了依赖于本地系统配置的选项。
https://stackoverflow.com/questions/33347189
复制相似问题