36

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

5
  • 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
    Commented Apr 25, 2014 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. Commented Jul 10, 2014 at 17:19
  • installing apple-gcc42 via brew fixed this for me. Thanks! Commented Sep 8, 2014 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
    Commented Oct 21, 2014 at 18:53
  • 3
    Don't run configure with sudo... What are you thinking?
    – rubenvb
    Commented Nov 19, 2014 at 8:26

11 Answers 11

17

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.

6
  • 1
    i had the same issue and your solution works great!! :)
    – Dilberted
    Commented Mar 4, 2015 at 11:05
  • 3
    It would help better if you gave an example of how to run gcc! Commented Oct 25, 2016 at 9:26
  • 2
    Launch the command line (wikihow.com/Get-to-the-Command-Line-on-a-Mac) and then type: gcc Commented Oct 25, 2016 at 14:05
  • sudo gcc worked for me. This answer helped me too, after all these years this still blindsides me when I least expect it. Commented Dec 31, 2016 at 21:50
  • 1
    I get the error gcc: fatal error: no input files or gcc: error: unrecognized command line option ‘--’ when I try the above 2 options Commented Apr 27, 2020 at 3:24
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.

1
  • brew install apple-gcc42 fixes the problem with readline but then I can't install sqlite
    – ilciavo
    Commented Mar 12, 2015 at 20:30
6

For me the issue was I had not run

xcode-select --install

Once I did that everything ran fine

1
  • 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 Commented Jan 31, 2019 at 13:51
3
sudo ln -s \ 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
3
  • 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. Commented Mar 29, 2016 at 3: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
    Commented Apr 4, 2016 at 6: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
    Commented Apr 28, 2016 at 4:07
3

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

sudo xcode-select --switch /Applications/Xcode.app
2
sudo gcc --version

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

1
  • gcc --version
    – xgMz
    Commented Jan 23, 2020 at 20:01
2

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
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
2
  • 1
    What's wrong with using clang installed with Xcode?
    – trojanfoe
    Commented Nov 19, 2014 at 9: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
    Commented Mar 12, 2015 at 20:33
1

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

0
0

In my case, a user-defined function which wraps gcc was the evil:

function gcc() {
    ...
}

So the solution was just to unset the function:

unset -f gcc
-1

If you are seeing this issue and you have already run xcode select --install, it might be because you need the 'Xcode Developer Tools' app from the app store. I installed it and the problem was resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.