LoginSignup
19
14

More than 5 years have passed since last update.

Ubuntu 14.04 に GCC 4.9 をインストールする

Last updated at Posted at 2016-02-20

あらまし

GCC 4.9がUbuntu 14.04標準パッケージとして用意されていない。
PPAからインストールを行う。

PPAの追加

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

パッケージのインストール

sudo apt-get update
sudo apt-get install g++-4.9

update-alternatives の導入

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

sudo rm /usr/bin/cpp
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-4.8 10
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-4.9 20

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

バージョン確認

$ gcc --version
gcc (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
Copyright (C) 2015 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.

$ g++ --version
g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
Copyright (C) 2015 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.

$ cpp --version
cpp (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
Copyright (C) 2015 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.

参考

Getting + installing gcc/g++ 4.9 on Ubuntu?
http://askubuntu.com/questions/428198/getting-installing-gcc-g-4-9-on-ubuntu

Choose gcc and g++ version
http://askubuntu.com/questions/26498/choose-gcc-and-g-version

Handling the GNU Compiler Collection with debian alternatives
http://blog.renaud.io/2011/10/06/handling-the-gnu-compiler-collection-with-debian-alternatives/

19
14
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
19
14