桜、抹茶、白、日記

名古屋市在住のC++使いのcoderの日記だったもの。

CentOSでDeveloper Toolsetを使う

CentOSではまだ公式にDeveloper ToolsetやSoftware Collectionsが提供されていないようですが、Developer Toolsetの野良リポジトリを使ってCentOS 5/6で最新版のgccを簡単にセットアップする方法。

Red Hat Developer Toolset
https://access.redhat.com/site/documentation/Red_Hat_Developer_Toolset/

Red HatRHELの開発環境をアップデートする「Developer Toolset 2.0」および「Software Collections 1.0」をリリース
http://sourceforge.jp/magazine/13/09/13/151500

Developer Toolsetのセットアップ

公式っぽい?のは以下にありますが・・・、

今回はこのリポジトリを使う設定をYUMに追加する。

$ su
# cd /etc/yum.repo.d
# vi devtool-puias.repo

devtool-puias.repoの中身

[devtools-puias]
name=Developer Toolset Repository for RHEL $releasever by puias
baseurl=http://puias.princeton.edu/data/puias/DevToolset/$releasever/$basearch
gpgcheck=0
enabled=0

準備が出来たらYUMでv1.1とv2.0をインストール。

# yum install  --enablerepo=devtools-puias  devtoolset-1.1  devtoolset-2
# ls -l /opt/rh
devtoolset-1.1
devtoolset-2
# scl -l
devtoolset-1.1
devtoolset-2

SCLの環境の利用

「scl enable <環境名> <コマンド>」の形式でSCL(Software Collection)の環境を呼び出す。<コマンド>にシェル(sh, bash, zsh, etc.)を指定する事で、SCL環境でコマンドが実行出来るようになる。

$ scl enable devtoolset-1.1 sh
$ g++ -v
gcc version 4.7.2
$ exit
$ scl enable devtoolset-2 zsh
$ gfortran -v
gcc version 4.8.1
$ exit