LoginSignup
0
0

More than 5 years have passed since last update.

vagrantのg++をデフォルトでC++11に対応させる

Last updated at Posted at 2017-02-12

http://www.task-notes.com/entry/20151114/1447492231
こちらのページを参考に入れたのですが

$ echo 'source /opt/rh/devtoolset-3/enable' >> /etc/profile.d/devtools

権限がありません

$ sudo -i
$ echo 'source /opt/rh/devtoolset-3/enable' >> /etc/profile.d/devtools

としてもvagrantにログインするたびにg++のバージョンが戻ってしまいました。
色々調べたら以下で解消できましたのでメモです。

sshログインします

$ vagrant ssh

g++(私の場合デフォ4.4)がどこにあるか確認してみます

$ which g++

私の場合
/usr/bin/g++
でした。

参考
http://qiita.com/phanect/items/45c67fa55d624e45367b

一旦rootユーザーになってみて、g++(4.9)がどこにあるか確認してみます

$ sudo -i
$ which g++

私の場合
/opt/rh/devtoolset-3/root/usr/bin/g++
でした。

そこでデフォルトで
/opt/rh/devtoolset-3/root/usr/bin/g++
を使うようにします。
それにはホームディレクトリ直下にある.bash_profileにPATH情報を記載します。

rootから抜けます

$ exit

.bash_profileは隠しファイルなのでそれも含んだディレクトリ構成を見ます。

$ ls -a

私の場合
. .bash_profile .pki
.. .bash_profile.2016-05-26@08:16:14~ .rbenv
.ansible .bash_profiles .ssh
.bash_history .bashrc .vbox_version
.bash_logout .mysql_history centos65
でした。

root権限で書き加えます

$ sudo vi .bash_profile

PATH=/opt/rh/devtoolset-3/root/usr/bin:$PATH
export PATH

これで4.9の方が優先して読み込まれます。

[参考]
http://pocketstudio.jp/linux/?%A5%D1%A5%B9(PATH)%A4%CE%B3%CE%C7%A7%A4%C8%C0%DF%C4%EA%CA%FD%CB%A1%A4%CF%A1%A9
http://archive.blog.hekt.org/archives/4827/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0