如何在 Linux Mint 上安装 GCC 4.7.2?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12991401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install GCC 4.7.2 on Linux Mint?
提问by Pippo
I need to install the latest version of GCC on Linux Mint 13. I found some useful terminal commands for Ubuntu 12.04, but it seems that nothing similar for Mint exists on the Internet...
我需要在 Linux Mint 13 上安装最新版本的 GCC。我发现了一些适用于 Ubuntu 12.04 的有用终端命令,但似乎 Internet 上没有类似 Mint 的命令......
Edit: I solved the problem, so, in order to help everybody else, write these commands:
编辑:我解决了这个问题,所以,为了帮助其他人,写下这些命令:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get update
sudo apt-get install g++-4.7 c++-4.7
sudo apt-get install g++-4.7 c++-4.7
And everything works fine. :)
一切正常。:)
回答by grasingerm
To find a specific package type
查找特定的包裹类型
apt-cache search "package"
In your case "gcc". Mine showed at least 40 different gnu compiler packages to choose from. The one it sounds like you want is gcc-4.7-base. Also you could update apt-get
before searching.
在你的情况下“gcc”。我的显示至少有 40 种不同的 gnu 编译器包可供选择。听起来你想要的是 gcc-4.7-base。您也可以apt-get
在搜索之前更新。
sudo apt-get update
回答by StarlitGhost
I built it from source when I did this not too long ago.
不久前,当我这样做时,我从源代码构建了它。
I followed the instructions here, but I downloaded and extracted gcc 4.7.2 first instead of last and replaced steps 3 to 5 with running this script that comes with it (which does those steps for you):
我按照此处的说明进行操作,但我首先下载并提取了 gcc 4.7.2,而不是最后,并通过运行随附的脚本(它为您执行这些步骤)替换了步骤 3 到 5:
gcc-4.7.2/contribs/download_prerequisites
gcc-4.7.2/contribs/download_prerequisites
You can download the gcc sources from one of the mirror sites: http://gcc.gnu.org/mirrors.html
您可以从以下镜像站点之一下载 gcc 源代码:http: //gcc.gnu.org/mirrors.html
Edit:added the instructions in-post
编辑:在帖子中添加了说明
Download and extract g++-4.7.2
$sudo apt-get install gcc-multilib m4
In order to compensate for insufficient path information, added this to .bashrc
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/usr/lib/i386-linux-gnu export
export C_INCLUDE_PATH=/usr/include/i386-linux-gnu export
export CPLUS_INCLUDE_PATH=/usr/include/i386-linux-gnu
Add these symlinks for the same reason:
$sudo ln -s /usr/include/i386-linux-gnu/gnu/stubs-32.h /usr/include/gnu
$sudo ln -s /usr/lib/i386-linux-gnu/crti.o /usr/lib/crti.o
$sudo ln -s /usr/lib/i386-linux-gnu/crt1.o /usr/lib/crt1.o
$sudo ln -s /usr/lib/i386-linux-gnu/crtn.o /usr/lib/crtn.o
$sudo ln -s /usr/local/lib/libmpc.so.3 /usr/lib/libmpc.so.3
run gcc-4.7.2/contribs/download_prerequisites
configure, make, make install
下载并解压 g++-4.7.2
$sudo apt-get install gcc-multilib m4
为了弥补路径信息不足,在.bashrc中添加了这个
导出 LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
导出 LIBRARY_PATH=/usr/lib/i386-linux-gnu 导出
export C_INCLUDE_PATH=/usr/include/i386-linux-gnu export
export CPLUS_INCLUDE_PATH=/usr/include/i386-linux-gnu
出于同样的原因添加这些符号链接:
$sudo ln -s /usr/include/i386-linux-gnu/gnu/stubs-32.h /usr/include/gnu
$sudo ln -s /usr/lib/i386-linux-gnu/crti.o /usr/lib/crti.o
$sudo ln -s /usr/lib/i386-linux-gnu/crt1.o /usr/lib/crt1.o
$sudo ln -s /usr/lib/i386-linux-gnu/crtn.o /usr/lib/crtn.o
$sudo ln -s /usr/local/lib/libmpc.so.3 /usr/lib/libmpc.so.3
运行 gcc-4.7.2/contribs/download_prerequisites
配置,制作,制作安装