The GCC distributed with CentOS 6 is 4.4.7, which is pretty outdated. I'd like to use gcc 4.8+. Also, when trying to install Linuxbrew you run into a dependency loop where Homebrew's gcc depends on zlib, which depends on gcc. Here's how I solved the problem.
Note: Requires sudo
privileges.
- http://superuser.com/a/676337/88393: Forum response on using CERN's open Scientific Linux distribution of RHEL's developer toolset.
- http://linux.web.cern.ch/linux/devtoolset/: CERN's developer toolset installation instructions.
- https://github.com/Homebrew/linuxbrew/wiki/Standalone-Installation: Instructions for a standalone installation of Homebrew.
- https://twitter.com/sjackman: Shaun Jackman -- the hero who maintains Linuxbrew.
First, verify which version of CentOS you're using:
$ cat /etc/centos-release
CentOS release 6.7 (Final)
Import CERN's GPG key:
sudo rpm --import http://ftp.scientificlinux.org/linux/scientific/5x/x86_64/RPM-GPG-KEYs/RPM-GPG-KEY-cern
Save repository information as /etc/yum.repos.d/slc6-devtoolset.repo
on your system:
wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
Install:
sudo yum install devtoolset-2
Enable the environment:
scl enable devtoolset-2 bash
Test the environment:
$ gcc --version
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
...
$ g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
...
$ gfortran --version
GNU Fortran (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
...
Optional: Permanently enable scl toolchain by putting this in your .bashrc
(warning: don't try to use the scl enable devtoolset-2 bash
command from before in your .bashrc. This spawns a new bash shell, and if that's in your .bashrc, it creates a new shell, which loads your .bashrc, which creates a new shell, etc.)
source /opt/rh/devtoolset-2/enable
Enable the SCL environment:
scl enable devtoolset-2 bash
Create symlinks to your new gcc/g++/gfortran:
ln -s $(which gcc) `brew --prefix`/bin/gcc-$(gcc -dumpversion |cut -d. -f1,2)
ln -s $(which g++) `brew --prefix`/bin/g++-$(g++ -dumpversion |cut -d. -f1,2)
ln -s $(which gfortran) `brew --prefix`/bin/gfortran-$(gfortran -dumpversion |cut -d. -f1,2)
Install Linuxbrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
Add these to your .bashrc
, and source it:
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
Test your installation:
brew install hello
brew test hello
brew remove hello
Who can tell me how to resolve C/CXX compiler identification is unknown issue? (RHEL 6 install gcc-4.8.2)
I follow below to install but looks like the compiler is not properly installed
sudo wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
sudo rpm --import http://ftp.scientificlinux.org/linux/scientific/5x/x86_64/RPM-GPG-KEYs/RPM-GPG-KEY-cern
sudo yum install devtoolset-2-gcc-c++-4.8.2-15.1.el6
echo "source /opt/rh/devtoolset-2/enable" >> ~/.bashrc
Building for SHARP
-- # The C compiler identification is unknown
-- # The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
I got GCC version 4.8.2 that is fine
cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/opt/rh/devtoolset-2/root/usr --mandir=/opt/rh/devtoolset-2/root/usr/share/man --infodir=/opt/rh/devtoolset-2/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --with-mpc=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
Thanks!