I'm using python 3.4
and I'm going to be wrapping some cpp files that use some of the new c++ language features along with openmp, however, I'm having some trouble getting it to work. I've installed gcc5 using brew and I can compile my cpp files just fine. When I try to wrap them into pyx files, I get compiler errors. Here is my setup.py
:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import os
os.environ["CC"] = "/usr/local/Cellar/gcc/5.2.0/bin/g++-5"
os.environ["CXX"] = "/usr/local/Cellar/gcc/5.2.0/bin/g++-5"
modules = [Extension("constellation",
["constellation.pyx"],
language="c++",
extra_compile_args=["-std=c++1y"])]
for e in modules:
e.cython_directives = {"embedsignature": True}
setup(name="constellation",
cmdclass={"build_ext": build_ext},
ext_modules=modules)
Running
python3 setup.py build_ext --inplace
I get a ton of these errors:
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
/var/folders/33/vsltc7m51l77bd5qlw3bwxzm0000gn/T//ccuePcPk.s:39:bad register name `%rdi)'
/var/folders/33/vsltc7m51l77bd5qlw3bwxzm0000gn/T//ccuePcPk.s:40:bad register name `%rdi)'
/var/folders/33/vsltc7m51l77bd5qlw3bwxzm0000gn/T//ccuePcPk.s:41:bad register name `%rdi)'
/var/folders/33/vsltc7m51l77bd5qlw3bwxzm0000gn/T//ccuePcPk.s:101:bad register name `%rbx'
...
/var/folders/33/vsltc7m51l77bd5qlw3bwxzm0000gn/T//cca3Gn0U.s:15821:Rest of line ignored. 1st junk character valued 64 (@).
error: command '/usr/local/Cellar/gcc/5.2.0/bin/g++-5' failed with exit status 1
If I change the compiler to the normal g++
, it works fine and compiles with Apple LLVM version 6.1.0 (clang-602.0.53)
Does anyone know what's happening? Would it be better to build a static or dynamic library and wrap that instead? If you can't tell, I'm pretty new to Cython. Any advice is greatly appreciated!