I'm using OSX v10.11.6 with a recent version of xcode installed. So my default compiler is gcc, which is really clang. I have used homebrew to install gcc5 so that I can use openMP, and by setting CC := g++-5 in my Makefiles for my source code in C, I can successfully compile C source code with non-trivial usage of -fopenmp.
What I want to do is get Cython to compile with gcc5 so that I can use Cython's native prange feature, as demonstrated in a minimal example here. I have written a minimal example in this gist, borrowed from the Neal Hughes page. When I attempt to compile omp_testing.pyx using setup.py, I get a (possibly unrelated) warning, and fatal error:
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
omp_testing.cpp:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^
error: command 'g++-5' failed with exit status 1
After reading How to tell distutils to use gcc?, what I attempted was setting the CC environment variable inside setup.py, but this did not work. How should I modify my Cython setup.py file to compile using g++-5?
setup.pydoes (at least) two things. It uses Cython to process your.pyxfile to a.cfile and it then it uses your C compiler to compile the C file. If Cython fails to process the.pyxit will produce some helpful error output telling you why it's unhappy and it will produce aomp_testing.cfile that contains an#errorline which tells any C compiler to stop. You should see some additional error messages when you runsetup.py(the first few are usually most helpful). Failing that you can runcython omp_testing.pyxfrom the command line yourself to see what's wrong.