Linux 安装旧版本的 gcc

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7854752/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 06:48:03  来源:igfitidea点击:

Installing older version of gcc

c++clinuxgccubuntu

提问by MetallicPriest

I want to install gcc 4.1.2 on my Ubuntu 64 bit system, which currentcly has gcc 4.4. I want to keep on using the current gcc, but want to add gcc 4.1.2 as well. Any simple way to do it, that is install gcc 4.1.2 on my system?

我想在我的 Ubuntu 64 位系统上安装 gcc 4.1.2,它当前有 gcc 4.4。我想继续使用当前的 gcc,但也想添加 gcc 4.1.2。有什么简单的方法可以做到,那就是在我的系统上安装 gcc 4.1.2?

回答by thiton

sudo apt-get install gcc-4.1=4.1.2 gcc-4.4

seems the straightforward solution to me. Since @DirkEddelbuettel noted that newer Ubuntu distributions dropped it, add an older distribution that has gcc-4.1 to your /etc/apt/sources.list. The Ubuntu people maintain a great websitefor looking that up; hardy, lucid and maverick seem great.

对我来说似乎是直接的解决方案。由于@DirkEddelbuettel 注意到较新的 Ubuntu 发行版已删除它,因此将具有 gcc-4.1 的旧发行版添加到您的 /etc/apt/sources.list。Ubuntu 人维护了一个很好的网站来查找;耐寒、清醒和特立独行似乎很棒。

回答by Dirk Eddelbuettel

Easy, just take it from an archive of the older Ubuntu releases. For example, my machine (still running natty) has

很简单,只需从较旧的 Ubuntu 版本的存档中获取即可。例如,我的机器(仍在运行 natty)有

edd@max:~$ ls -l /usr/bin/g++-*
-rwxr-xr-x 1 root root 242752 2010-09-10 04:16 /usr/bin/g++-4.3
-rwxr-xr-x 1 root root 263240 2011-03-31 15:22 /usr/bin/g++-4.4
-rwxr-xr-x 1 root root 275856 2011-04-18 09:25 /usr/bin/g++-4.5
edd@max:~$

The 4.1.* series had some issues. Even g++-4.2.1, the default on OS X, is not all that great. But you should definitely have the option of installing this.

4.1.* 系列有一些问题。即使是 OS X 上的默认值 g++-4.2.1,也不是那么好。但是您绝对应该可以选择安装它。

When you do this, by all means go the package management route of installing proper dependencies. You will get matching packages for the other dependencies too.

当你这样做时,一定要走安装适当依赖项的包管理路线。您也将获得其他依赖项的匹配包。

In other words, you need to adjust /etc/apt/sources.listto point to an older release that had this version.

换句话说,您需要进行调整/etc/apt/sources.list以指向具有此版本的旧版本。

回答by B?ови?

This should do :

这应该做:

sudo apt-get install gcc-4.1=4.1.2-27ubuntu1 gcc-4.1-base=4.1.2-27ubuntu1 cpp-4.1=4.1.2-27ubuntu1 g++-4.1

Other way is to download gcc 4.1.2 and dependent libraries, and compile it yourself.

另一种方式是下载gcc 4.1.2和依赖库,自己编译。

回答by Martin York

Once installed see others:

安装后查看其他人:

Use the -V flag to run a particular version:

使用 -V 标志运行特定版本:

-V <version>             Run gcc version number <version>, if installed