Ubuntu 12.04 & 13.04 安装 GCC4.8.1

Ubuntu 12.04 & 13.04 安装 GCC4.8.1

分类: C++ 1358人阅读 评论(0) 收藏 举报

终于有了完整实现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

先安装一个软件

[plain] view plain copy print ?
  1. apt-get install python-software-properties
apt-get install python-software-properties

然后

[plain] view plain copy print ?
  1. sudo add-apt-repository ppa:ubuntu-toolchain-r/test
  2. sudo apt-get update
  3. sudo update-alternatives --remove-all gcc
  4. sudo update-alternatives --remove-all g++
  5. sudo apt-get install gcc-4.8
  6. sudo apt-get install g++-4.8
  7. sudo apt-get install gcc-4.8-multilib
  8. sudo apt-get install g++-4.8-multilib
  9. sudo apt-get install gcc-4.8-doc
  10. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
  11. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
  12. sudo update-alternatives --config gcc
  13. sudo update-alternatives --config g++
  14. sudo apt-get update
  15. sudo apt-get upgrade -y
  16. sudo apt-get dist-upgrade
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.

[plain] view plain copy print ?
  1. gcc --version
  2. gcc (Ubuntu 4.8.1-2ubuntu1~13.04) 4.8.1
  3. Copyright (C) 2013 Free Software Foundation, Inc.
  4. This is free software; see the source for copying conditions. There is NO
  5. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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 错误

创建两个链接来解决:

[plain] view plain copy print ?
  1. ln -s /usr/bin/g++ /etc/alternatives/c++
  2. ln -s /etc/alternatives/c++ /usr/bin/c++
ln -s /usr/bin/g++ /etc/alternatives/c++
ln -s /etc/alternatives/c++ /usr/bin/c++


同样,遇到cc找不到的时候,也创建链接:

[plain] view plain copy print ?
  1. ln -s /usr/bin/gcc /etc/alternatives/cc
  2. ln -s /etc/alternatives/cc /usr/bin/cc
ln -s /usr/bin/gcc /etc/alternatives/cc
ln -s /etc/alternatives/cc /usr/bin/cc



安装的文件可以通过下面的命令查找:

[plain] view plain copy print ?
  1. dpkg -L gcc-4.8
  2. /.
  3. /usr
  4. /usr/bin
  5. /usr/bin/gcc-ranlib-4.8
  6. /usr/bin/gcov-4.8
  7. /usr/bin/gcc-ar-4.8
  8. /usr/bin/gcc-nm-4.8
  9. /usr/bin/gcc-4.8
  10. /usr/lib
  11. /usr/lib/gcc
  12. /usr/lib/gcc/x86_64-linux-gnu
  13. /usr/lib/gcc/x86_64-linux-gnu/4.8
  14. /usr/lib/gcc/x86_64-linux-gnu/4.8/lto1
  15. /usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
  16. /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2
  17. /usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.spec
  18. /usr/lib/gcc/x86_64-linux-gnu/4.8/libitm.spec
  19. /usr/share
  20. /usr/share/doc
  21. /usr/share/doc/gcc-4.8-base
  22. /usr/share/doc/gcc-4.8-base/README.ssp
  23. /usr/share/doc/gcc-4.8-base/gomp
  24. /usr/share/doc/gcc-4.8-base/gomp/changelog.gz
  25. /usr/share/doc/gcc-4.8-base/changelog.gz
  26. /usr/share/doc/gcc-4.8-base/gcc
  27. /usr/share/doc/gcc-4.8-base/gcc/changelog.gz
  28. /usr/share/doc/gcc-4.8-base/NEWS.html
  29. /usr/share/doc/gcc-4.8-base/README.Bugs
  30. /usr/share/doc/gcc-4.8-base/test-summary.gz
  31. /usr/share/doc/gcc-4.8-base/itm
  32. /usr/share/doc/gcc-4.8-base/itm/changelog.gz
  33. /usr/share/doc/gcc-4.8-base/quadmath
  34. /usr/share/doc/gcc-4.8-base/quadmath/changelog.gz
  35. /usr/share/doc/gcc-4.8-base/NEWS.gz
  36. /usr/share/man
  37. /usr/share/man/man1
  38. /usr/share/man/man1/gcov-4.8.1.gz
  39. /usr/share/man/man1/gcc-nm-4.8.1.gz
  40. /usr/share/man/man1/gcc-4.8.1.gz
  41. /usr/share/man/man1/gcc-ar-4.8.1.gz
  42. /usr/share/man/man1/gcc-ranlib-4.8.1.gz
  43. /usr/bin/x86_64-linux-gnu-gcc-ranlib-4.8
  44. /usr/bin/x86_64-linux-gnu-gcc-4.8
  45. /usr/bin/x86_64-linux-gnu-gcc-nm-4.8
  46. /usr/bin/x86_64-linux-gnu-gcc-ar-4.8
  47. /usr/share/doc/gcc-4.8
  48. /usr/share/man/man1/x86_64-linux-gnu-gcc-4.8.1.gz

你可能感兴趣的:(C++)