Compile Node with GCC v4.9.2

Mick asked:

I can’t seem to be able to compile Node.js on CentOS 6.6 (64 bits) GCC v4.9.2

$ ./configure
Node.js configure error: No acceptable C compiler found!

        Please make sure you have a C compiler installed on your system and/or
        consider adjusting the CC environment variable if you installed
        it in a non-standard prefix.

More details:

$ which gcc

$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-current/configure --enable-languages=c,c++,fortran --enable-multilib --prefix=/usr/local/gcc
Thread model: posix
gcc version 4.9.2 (GCC)

$ which python

$ python --version
Python 2.6.6

I have tried to set CC..

$ CC="/usr/local/gcc/bin/gcc"

$ set | grep CC

but it leads to the same error.

Any ideas?

Edit 1 – Michael’s Question

What happened to the compiler the system came up with?

I have installed a newer version of the compiler (v4.9.2) in /usr/local/gcc, and removed the original compiler (v4.4.7) and tried to replace it that way:

yum remove -y gcc gcc-c++ cpp

sudo mv /usr/bin/g++  /usr/bin/g++_old
sudo mv /usr/bin/c++ /usr/bin/c++_old

sudo ln -s -f /usr/local/gcc/bin/gcc  /usr/bin/gcc
sudo ln -s -f /usr/local/gcc/bin/g++  /usr/bin/g++
sudo ln -s -f /usr/local/gcc/bin/c++ /usr/bin/c++
sudo ln -s -f /usr/local/gcc/bin/cpp /usr/bin/cpp
sudo ln -s -f /usr/local/gcc/bin/gfortran /usr/bin/gfortran
sudo ln -s -f /usr/local/gcc/bin/gcov /usr/bin/gcov

sudo cp /usr/local/gcc/lib64/ /usr/lib64/.
sudo mv /usr/lib64/ /usr/lib64/
sudo ln -s -f /usr/lib64/ /usr/lib64/

I am doing this because I am installing HHVM on this system which needs a recent compiler.

My answer:

That compiler setup may work for hhvm, but it’s pretty useless for anything else. It’s quite difficult to have two gcc versions on the same system. You could do something like use a Software Collection, but I personally don’t like those as they are not very easy to use.

You should be using CentOS 7, anyway, as it won’t require you to replace the compiler, and more things will be current. Overall, basing the system on C7 will pretty much solve all your problems anyway and be more future proof.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.