0

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.

Community
  • 1
  • 1
Paul
  • 165
  • 1
  • 1
  • 13
  • You may want to look at what environment variables are set that would affect either path or compiler operation. – Chad Kennedy Sep 29 '15 at 14:54
  • You shouldn't need that `--prefix` if the Xcode command line tools are installed (they get installed into `/usr/bin`). Use `xcode-select --install`. – Droppy Sep 29 '15 at 15:08
  • When I typed `xcode-select --install` this is what I got `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` @Droppy – Paul Sep 29 '15 at 15:25
  • OK drop the `--prefix` and use `CC=clang ./configure `. – Droppy Sep 29 '15 at 16:00
  • @Droppy Which file do I need to modify? – Paul Sep 29 '15 at 17:14
  • Did you maybe install `gcc` using `homebrew`? That would place it in `/usr/local/bin`. – Mark Setchell Sep 29 '15 at 21:29

1 Answers1

1

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).

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105