转自 http://blog.csdn.net/csfreebird/article/details/9626577
终于有了完整实现C++11的GCC 4.8.1.
给自己的系统升级吧。
下面的步骤可以安装GCC4.8.1, 内容来自:http://askubuntu.com/questions/312620/how-do-i-install-gcc-4-8-1-on-ubuntu-13-04
先安装一个软件
- apt-get install python-software-properties
然后
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo update-alternatives --remove-all gcc
- sudo update-alternatives --remove-all g++
- sudo apt-get install gcc-4.8
- sudo apt-get install g++-4.8
- sudo apt-get install gcc-4.8-multilib
- sudo apt-get install g++-4.8-multilib
- sudo apt-get install gcc-4.8-doc
- 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++
- sudo apt-get update
- sudo apt-get upgrade -y
- sudo apt-get dist-upgrade
最后用gcc --version检查一下,果然是4.8.1.
- gcc --version
- gcc (Ubuntu 4.8.1-2ubuntu1~13.04) 4.8.1
- 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.
如果编译的时候,出现/usr/bin/c++ not found 错误
创建两个链接来解决:
- ln -s /usr/bin/g++ /etc/alternatives/c++
- ln -s /etc/alternatives/c++ /usr/bin/c++
同样,遇到cc找不到的时候,也创建链接:
- ln -s /usr/bin/gcc /etc/alternatives/cc
- ln -s /etc/alternatives/cc /usr/bin/cc
安装的文件可以通过下面的命令查找:
- dpkg -L gcc-4.8
- /.
- /usr
- /usr/bin
- /usr/bin/gcc-ranlib-4.8
- /usr/bin/gcov-4.8
- /usr/bin/gcc-ar-4.8
- /usr/bin/gcc-nm-4.8
- /usr/bin/gcc-4.8
- /usr/lib
- /usr/lib/gcc
- /usr/lib/gcc/x86_64-linux-gnu
- /usr/lib/gcc/x86_64-linux-gnu/4.8
- /usr/lib/gcc/x86_64-linux-gnu/4.8/lto1
- /usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
- /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2
- /usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.spec
- /usr/lib/gcc/x86_64-linux-gnu/4.8/libitm.spec
- /usr/share
- /usr/share/doc
- /usr/share/doc/gcc-4.8-base
- /usr/share/doc/gcc-4.8-base/README.ssp
- /usr/share/doc/gcc-4.8-base/gomp
- /usr/share/doc/gcc-4.8-base/gomp/changelog.gz
- /usr/share/doc/gcc-4.8-base/changelog.gz
- /usr/share/doc/gcc-4.8-base/gcc
- /usr/share/doc/gcc-4.8-base/gcc/changelog.gz
- /usr/share/doc/gcc-4.8-base/NEWS.html
- /usr/share/doc/gcc-4.8-base/README.Bugs
- /usr/share/doc/gcc-4.8-base/test-summary.gz
- /usr/share/doc/gcc-4.8-base/itm
- /usr/share/doc/gcc-4.8-base/itm/changelog.gz
- /usr/share/doc/gcc-4.8-base/quadmath
- /usr/share/doc/gcc-4.8-base/quadmath/changelog.gz
- /usr/share/doc/gcc-4.8-base/NEWS.gz
- /usr/share/man
- /usr/share/man/man1
- /usr/share/man/man1/gcov-4.8.1.gz
- /usr/share/man/man1/gcc-nm-4.8.1.gz
- /usr/share/man/man1/gcc-4.8.1.gz
- /usr/share/man/man1/gcc-ar-4.8.1.gz
- /usr/share/man/man1/gcc-ranlib-4.8.1.gz
- /usr/bin/x86_64-linux-gnu-gcc-ranlib-4.8
- /usr/bin/x86_64-linux-gnu-gcc-4.8
- /usr/bin/x86_64-linux-gnu-gcc-nm-4.8
- /usr/bin/x86_64-linux-gnu-gcc-ar-4.8
- /usr/share/doc/gcc-4.8
- /usr/share/man/man1/x86_64-linux-gnu-gcc-4.8.1.gz