Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

"configure: error: C compiler cannot create executables"

I'm getting this error msg "configure: error: C compiler cannot create executables" which seems to be a recurring problem. There are lots of old answers to this, but those solutions don't seem to work for me. So, I'm asking this question again in 2020.


Mac OS 10.15.7 (Catalina)


Mac Xcode 11.6 (11E708)

Command Line Tools 11.5


$ which cc
/usr/bin/cc
$ ls -l /usr/bin/cc 
/usr/bin/cc -> clang
$ cc -v
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ which gcc
/opt/local/bin/gcc
$ ls -l /opt/local/bin/gcc -> /usr/bin/gcc
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ echo $CC
/opt/local/bin/gcc


I wonder if this is a problem with clang vs. using a real gcc from gnu?

MacBook Pro with Touch Bar

Posted on Nov 3, 2020 9:36 AM

Reply
Question marked as Best reply

Posted on Nov 3, 2020 10:41 AM

The solution (sorry I can't edit my previous posts.)


there is something wrong with the version check loop. If you remove all the tries except for --version (depending on your compiler) then it works.


So in the config file, change the line first line of the loop to this:


for ac_option in   --version  ; do
  { { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac

Similar questions

2 replies
Question marked as Best reply

Nov 3, 2020 10:41 AM in response to CA-Wind-Rider

The solution (sorry I can't edit my previous posts.)


there is something wrong with the version check loop. If you remove all the tries except for --version (depending on your compiler) then it works.


So in the config file, change the line first line of the loop to this:


for ac_option in   --version  ; do
  { { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac

Nov 3, 2020 10:09 AM in response to CA-Wind-Rider

(can't seem to edit my original post).


Further investigation: I brew reinstalled gcc and linked gcc to gcc-10

but the problem didn't go away.


I also tried bash instead of zsh (by editing the config file) and the problem didn't go away.


Looking at the config.log file I do see that this loop seems to have failed:


for ac_option in  -v --version -V -qversion ; do
  { { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac


It looks like the loop tries a number of permutations to get the version number (because different compilers do it differently.). Some how when it gets the right answer, it doesn't recognize it and continues until it hits the end and then dies.


configure:2734: checking for C compiler version
configure:2743: /opt/local/bin/gcc -v >&5
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/10.2.0/libexec/gcc/x86_64-apple-darwin19/10.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../configure --build=x86_64-apple-darwin19 --prefix=/usr/local/Cellar/gcc/10.2.0 --libdir=/usr/local/Cellar/gcc/10.2.0/lib/gcc/10 --di
sable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/l
ocal/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.2.0' --with-bugurl=h
ttps://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/Comma
ndLineTools/SDKs/MacOSX10.15.sdk SED=/usr/bin/sed
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Homebrew GCC 10.2.0) 
configure:2754: $? = 0
configure:2743: /opt/local/bin/gcc --version >&5
gcc (Homebrew GCC 10.2.0) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2754: $? = 0
configure:2743: /opt/local/bin/gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:2754: $? = 1
configure:2743: /opt/local/bin/gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.


I'm not sure why this standard config script that used to work is now failing. I got the code from here: http://www.chokkan.org/software/dist/simstring-1.0.tar.gz




"configure: error: C compiler cannot create executables"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.