Paul
Paul

Reputation: 175

Compilation error when using gcc in OSX 10.10.5

I am trying to install a python package by using python setup.py install but at some point of the installation procedure an error is raised:

gcc: error: x86_64: No such file or directory
gcc: error: unrecognized option ‘-arch’
error: command 'gcc' failed with exit status 1

Previously, I installed Xcode 7.0 and their respective Command Line Tools for Xcode 7. The compiler seems to be in which gcc local /usr/local/bin/gcc. However, when I tried gcc -v I got Segmentation fault: 11. Moreover, when I tried /usr/bin/gcc -v I got

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.0.72)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Then, the installed compiler seems to be in a different location. A similar issue was raised in Command line tool installed, but gcc/g++ compiler not working but there is not a clear solution to the problem. Do you have any idea how can I can fix it (link to the actual installed compiler to continue the installation of the Python package)? Thanks in advance.

Upvotes: 0

Views: 972

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54505

Expanding on @Droppy's comment: xcode doesn't install gcc in /usr/local/bin (OP did not clarify where it came from). MacPorts would put it in /opt/local/bin/gcc, but omit to select the current port. So CC=clang is the simplest way to answer it. However, OP is asking how to override it in setup.py.

That has been discussed in these questions:

The first is most pertinent, leading to this suggestion:

CC=/usr/bin/clang CFLAGS="-O" python setup.py build

(clang simply ignores most of the gcc options, not even giving a warning, but setting CFLAGS can help persuade the python script to not try options that clang is unlikely to support).

Upvotes: 1

Related Questions