CentOS 6.5で提供されるGCCは4.4.7と古く、一部のプログラム*1がコンパイルできないということもあったりする。
$ cat /etc/redhat-release CentOS release 6.5 (Final) $ gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4) Copyright (C) 2010 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.
そこでCentOS向けに作成されたRed Hat Developer ToolsetのレポジトリからGCCを入れてみる。
# wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo # yum install devtoolset-2-gcc devtoolset-2-binutils # yum install devtoolset-2-gcc-c++ devtoolset-2-gcc-gfortran
/opt/rh/devtoolset-2/root/以下にGCC4.8.2のライブラリなどがインストールされる。
$ /opt/rh/devtoolset-2/root/usr/bin/gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) 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.
また、同時にインストールされる(はず)sclというgccなどへのパス指定を変えてコマンドを実行してくれるツールを使えばわざわざ1つずつパス指定しなくてもコマンド1つで大丈夫。 scl enable devtoolset-2 (コマンド)のように使う。
$ scl enable devtoolset-2 bash $ gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) 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.
参考:yum - How to Install gcc 4.7.x/4.8.x on CentOS - Super User
*1:DarkcoinのCPUMinerとか