I have problems with including boost into my c++ code, which is complied using 'swig'. I want to c++ as a backend to my python stuff.
Calling these two commands
swig -c++ -python spherical_overlap.i
python setup.py build_ext --inplace
the latter gives me the following error
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>
The file is located there. I think I have to set the following flag for the compiler
-I /usr/local/include
The problem is, I do not know how to do that. Here is my 'setup.py' file
#!/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"],
)
You can do either of the following:
Add include_dirs = ['/usr/local/include'],
to the Extension
constructor call
Add the following to a file setup.cfg
:
[build_ext]
include-dirs = /usr/local/include
Specify the include-dirs
option to the build_ext
command, i.e., run
python setup.py build_ext --inplace --include-dirs /usr/local/include
Add -I/usr/local/include
to the CPPFLAGS
environment variable, e.g., run
CPPFLAGS="-I/usr/local/include" python setup.py build_ext --inplace
Probably the second is the preferred way, since it reflects options that depends on the local system configuration.