Upgrade GCC 4.6.3 on Ubuntu 12.04 to 4.8.2

坚强是说给别人听的谎言 提交于 2019-11-30 05:26:59

You can easily compile the sources.

The following commands worked for gcc 4.7. They should be fine for gcc 4.8 as well:

sudo apt-get install libmpfr-dev libgmp3-dev libmpc-dev flex bison

svn checkout svn://gcc.gnu.org/svn/gcc/trunk

cd trunk

./configure --prefix=/opt/gcc-4.8.2/usr/local/gcc-4.8.2 --enable-languages=c,c++

make

make install

The compiler will be placed in the /opt/ directory, so you have to use it from there.

  1. Add the ppa by

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

  2. Install g++ and gcc (version 4.8)

    sudo apt-get update; sudo apt-get install gcc-4.8 g++-4.8

  3. Run the following commands one by one,

    sudo update-alternatives --remove-all gcc

    sudo update-alternatives --remove-all g++

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

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

    sudo update-alternatives --config gcc

    sudo update-alternatives --config g++

That's it you are done!

Do you want to compile it yourself ? If not, there is a PPA, described here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!