OS X 10.9.2: checking whether the C compiler works… no

白昼怎懂夜的黑 提交于 2019-11-27 13:46:26

问题


I'm attempting to install texinfo 5.2, and I'm running into some issues during ./configure, which I believe are related to the C compiler. When I upgraded from Snow Leopard, I didn't perform a clean install, so perhaps that's part of the problem. Anyway, here's what I've got:

ryansmacbook:texinfo-5.2 ryan$ sudo ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64"                  CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64"                  CPP="gcc -E" CXXCPP="g++ -E"
Password:
checking for a BSD-compatible install... /usr/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '0' is supported by ustar format... yes
checking whether GID '0' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking for perl... /usr/bin/perl
checking Perl version and Encode module... yes
checking for gawk... (cached) awk
checking for gcc... gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64
checking whether the C compiler works... no
configure: error: in `/Users/ryan/Downloads/texinfo-5.2':
configure: error: C compiler cannot create executables
See `config.log' for more details

I've read some of the other questions related to this, so I attempted to install Command Line Tools.

ryansmacbook:~ ryan$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

So it seems they're not installed, although I'm running Xcode 5.1 installed from the App Store. From what I've read, Command Line Tools should be installed, but I've tried

$ xcode-select --install

anyway, and when I tell it to install, a message pops up saying "Can't install software because it is not currently available from the Software Update server."

I found what I thought might be a work-around at http://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/, so I did the following:

ryansmacbook:Tools ryan$ brew install coreutils
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Downloading http://ftpmirror.gnu.org/coreutils/coreutils-8.22.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/coreutils/8.22 --program-prefix=g --w
==> make install
==> Caveats
All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

    MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"

/usr/local/share/info/dir: Permission denied
==> Summary
🍺  /usr/local/Cellar/coreutils/8.22: 211 files, 10M, built in 2.4 minutes

But I still have the ./configure issue.

For reference,

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

Although I did attempt to install gcc-4.7 the other day, and it's currently living at

/usr/gcc-4.7.2/bin/gcc-4.7

I'm not quite sure how to get it to run as a command from the command line because

$ gcc-4.7 --version
-bash: gcc-4.7: command not found

is what I'm getting now, but that may be neither here nor there.

edit: Since this doesn't directly answer my question about checking whether the C compiler works, I'm not submitting this as an answer. I just tried brew install texinfo, and that worked like a charm. At this point, I can't really remember why I was trying to install texinfo from source nor can I remember what I needed it for (maybe something GNU Make-related or Emacs-related?).


回答1:


I faced this same problem after installing xcode; All I had to do was run gcc. This then asked me to accept the xcode license. After, it just worked fine.

Hope this helps someone.




回答2:


I can't really take credit for the answer, but the same things happened to me. I tried to get a ruby-1.9.3 ruby. RVM grabed gcc46 and told homebrew to install it. But then the rvm install command didn't like that. So brew uninstall gcc46 and then brew install apple-gcc42 worked like a charm.




回答3:


For me the issue was I had not run

xcode-select --install

Once I did that everything ran fine




回答4:


sudo ln -s \ 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain



回答5:


gcc -version

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.




回答6:


I had similar "checking whether the C compiler works... no" problem in my yosemite mac.

I checked some things:

$ which gcc
gcc: aliased to nocorrect gcc
$ ll /usr/bin/gcc
-rwxr-xr-x  1 root  wheel    14K 27 Sep 04:06 /usr/bin/gcc
$ gcc
gcc: fatal error: no input files
compilation terminated.
$ gcc --version
gcc: warning: couldn't understand kern.osversion '14.0.0
gcc (GCC) 4.8.3
Copyright (C) 2013 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.

Then I installed it doing:

$ brew install gcc
Error: You must `brew link cloog' before gcc can be installed
$ brew link cloog
Linking /usr/local/Cellar/cloog/0.18.1... 8 symlinks created
$ brew install gcc
Error: gcc-4.8.3 already installed
To install this version, first `brew unlink gcc'
$ brew unlink gcc
Unlinking /usr/local/Cellar/gcc/4.8.3... 39 symlinks removed
$ brew install gcc
....

And it worked:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix



回答7:


Similar problem while installing python3. My home brew was out dated. I simply update my home brew utility.



来源:https://stackoverflow.com/questions/22844522/os-x-10-9-2-checking-whether-the-c-compiler-works-no

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!