33

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

Ryan M
  • 647
  • 2
  • 6
  • 16
  • 2
    I had a similar error just now. I seem to have fixed it so this might help you. I had gcc46 installed via homebrew. That seemed to be the root of my problems. I uninstalled that and installed apple-gcc42 and now everything seems to build ok. I wasn't building the same thing as you though. – jeanaux Apr 25 '14 at 10:46
  • The command line tools are included in the Xcode bundle. There is a gcc executable in there. Just try `gcc --version` at the command line to see if you get any results. I'm not sure if it is a true gcc compiler though, it might just be an alias for the llvm compiler. – Aaron Bratcher Jul 10 '14 at 17:19
  • installing apple-gcc42 via brew fixed this for me. Thanks! – deepelement Sep 08 '14 at 15:40
  • OK. That worked. Except for the stuff that wants a more recent compiler... How can we compile libv8, for example? 4.2 doesn't seem to work. – nroose Oct 21 '14 at 18:53
  • 3
    Don't run `configure` with `sudo`... What are you thinking? – rubenvb Nov 19 '14 at 08:26

9 Answers9

16

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.

GeneralBecos
  • 2,476
  • 2
  • 22
  • 32
7

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.

Ben Johnson
  • 150
  • 1
  • 10
6

For me the issue was I had not run

xcode-select --install

Once I did that everything ran fine

kellyfj
  • 6,586
  • 12
  • 45
  • 66
  • 2
    Most elegant answer. I used it on MacOS Mojave (10.14) and it worked instantly. Developer Tools were updated some months ago, but for some reason that's not enough and this is needed to get ./configure working – Elise van Looij Jan 31 '19 at 13:51
3
sudo ln -s \ 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
olivetree123
  • 173
  • 3
  • 13
  • 3
    While this code may answer the question, providing additional context regarding *why* and/or *how* this code answers the question improves its long-term value. – Benjamin W. Mar 29 '16 at 03:30
  • Just working on OS X El Capitan and it reported a missing file call for `/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain`. Setting up a symlink as above and clang compiler works as expected. Command: `$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain` – Ken Pega Apr 04 '16 at 06:54
  • Solution works for OS X El Capitan. I have xcode installed, plus brew installed gcc 5.3 (with the xcode version first in my path, I just alias 5.3 in when I need the newer features of 5.3). Setting up the symlink as @olivetree123 suggested was THE fix that worked for me. The reason it works - if you root through a ton of log files, you'll see one little "hey, you're missing ...xctoolchain", so symlinking it from the default was the obvious choice. – P1xt Apr 28 '16 at 04:07
2
sudo gcc --version

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

Guy
  • 2,883
  • 1
  • 32
  • 39
2

I encountered this while setting up a React Native project. This solution worked.

sudo xcode-select --switch /Applications/Xcode.app
Nelu
  • 16,644
  • 10
  • 80
  • 88
1

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
santifinland
  • 216
  • 2
  • 5
  • 1
    What's wrong with using `clang` installed with Xcode? – trojanfoe Nov 19 '14 at 09:05
  • Some packages support `gcc` only... Getting everything to work with `gcc` is not that trivial since the whole operating system was designed with `clang` – ilciavo Mar 12 '15 at 20:33
1

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

GDSM
  • 166
  • 2
  • 7
1

I faced a similar problem but my situation was different.

I had the Xcode with spaces in the app name removing those spaces fixed the problem:

sudo xcode-select --switch /Applications/Xcode14.0.app
Charlisim
  • 46
  • 1
  • 6