1

When trying to install scikit on my Mac (OS X Lion) I stumbled upon this error:

gcc-4.2 not found, using clang instead.

I searched how to fix this and it seems that the environment variable CC is not correctly set. My question now is, how can I change this and to what do I have to change this? In my /usr/lib/ I do see the g++, gcc, llvm-g++-4.2 and llvm-gcc-4.2 executables. Also when I check env I don't see the CC variable. Even when I try to export CC=gcc I don't see it with the env command.

dda
  • 6,030
  • 2
  • 25
  • 34
Olivier_s_j
  • 5,490
  • 24
  • 80
  • 126
  • If `export CC=gcc` doesn't show up in the output of `env`, you have a problem, or a non-sh shell like `tcsh`. `echo $SHELL` should tell you the shell. And make sure you didn't miss `CC` in the output of `env`, eg: `env | grep CC`. –  Dec 05 '12 at 13:52
  • when I do printenv CC , I do see gcc , the error states that It can't find gcc-4.2 ... – Olivier_s_j Dec 05 '12 at 14:01
  • 1
    Btw, if you're installing through `python setup.py build/install`, you can prepend that line with `CC=/usr/bin/gcc python setup.py build` (and possibly other variables for e.g. the c++ compiler). –  Dec 05 '12 at 14:04
  • And is this the right compiler to use ? Because there is this llvm-gcc-4.2 one too it seems – Olivier_s_j Dec 05 '12 at 14:06
  • Which scikit btw? If I know which one, I could be tempted to give the instllation procedure a try myself. Note that my Mac with Lion does have /usr/bin/gcc-4.2, so I don't know where yours went... –  Dec 05 '12 at 14:49
  • well I took the one from github, which was not a good idea. I tried it with pip, but there were problem concerning numpy ... I don't understand why I have these many problems when they are all newly installed – Olivier_s_j Dec 05 '12 at 19:38
  • that's not what I meant. There are multiple scikits: scikits-learn, scikits-image, scikits-fitting etc., and they're all hosted on github. I would guess you installed scikits-learn, but perhaps you meant *all* of them? –  Dec 06 '12 at 10:19

3 Answers3

2

There are multiple ways of doing this:

  1. If you are using make to compile the sources, use the following command:

    make CC=/path/to/gcc CXX=path/to/g++ 
    make CC=/path/to/gcc CXX=path/to/g++ install 
    etc.
    
  2. You could permanently change your default compilers by:

    cd /usr/bin
    rm cc c++ gcc g++
    ln -s gcc-4.2 cc
    ln -s gcc-4.2 gcc
    ln -s c++-4.2 c++
    ln -s g++-4.2 g++
    

You should also give clang a try, though - it's not bad at all, and in many cases is known to produce equivalent or better-optimized programs than gcc.

hopper
  • 13,060
  • 7
  • 49
  • 53
RamneekHanda
  • 171
  • 5
1

If scikits is explicitly looking for gcc-4.2, it sounds like it's hardcoded in the setup procedure (bad idea i.m.o.).

I would then just go for the symlink solution; a bit different than my comment or Ramneek's answer, but pretty much the same:

sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
0

gcc and such shouldn't be in /usr/lib/, but (also) in /usr/bin/. The ones in /usr/lib/ are subdirectories, the ones in /usr/bin/ are the executables.

It may very well be that you have the libraries in those subdirectories, but not the actual executables and header files.

Have you installed the command-line tools during your XCode installation?

  • I have the command-line tools installed and I see gcc and g++ in /usr/bin/ (but no gcc-4.2) – Olivier_s_j Dec 05 '12 at 13:57
  • You can of course always symlink `gcc-4.2` to `gcc`, but you shouldn't have to. Have you checked your shell; you'll need to find out why you can set `CC` as an environment variable. –  Dec 05 '12 at 14:03