在Debian 8.7上安装g ++ 7.0.1

Rob*_*t D 6 c++ linux debian gcc g++

我已经尝试了一段时间在我的Debian机器上安装g ++ 7.我能够很容易地在我的Mac上安装它(因为自制软件有一个公式).但是我似乎找不到在Linux上安装它的方法.

这个人有一个关于安装g ++ 4.9 的线程,并且改变他给出的网址引导我进入这个页面,这似乎是朝着正确的方向......但我想这样安装它可能会导致一些潜在的问题当我想更新这些包时.

有没有我缺少的消息来源?或者是否有一个地方可以下载并编译我需要的所有内容以使其运行?

谢谢您的帮助.

有用的数据:
我的内核是x86_64 Linux 3.16.0-4-amd64.

编辑:按照迪特里希的建议,我现在遇到一个新的错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-7 : Depends: cpp-7 (= 7-20170316-1) but it is not going to be installed
         Depends: libcc1-0 (>= 7-20170316-1) but it is not going to be installed
         Depends: binutils (>= 2.28) but 2.25-5+deb8u1 is to be installed
         Depends: libgcc-7-dev (= 7-20170316-1) but it is not going to be installed
         Depends: libisl15 (>= 0.15) but it is not installable
         Depends: libmpfr4 (>= 3.1.3) but 3.1.2-2 is to be installed
         Depends: libstdc++6 (>= 5) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

这就是我的sources.list设置方式:

#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN REPOS                    
#------------------------------------------------------------------------------#

###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free 
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free 

###### Debian Update Repos
deb http://security.debian.org/ jessie/updates main contrib non-free 
deb http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free 
deb-src http://security.debian.org/ jessie/updates main contrib non-free 
deb-src http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free 

###### For ffmpeg
deb http://www.deb-multimedia.org jessie main non-free

###### For gcc-7 (Experimental)
deb http://httpredir.debian.org/debian experimental main
Run Code Online (Sandbox Code Playgroud)

正如你所说的那样,我猜这是我在Debian稳定的问题吗?为了解决这个错误,我需要做些什么,同时保持稳定?

编辑2:好的,所以我想出了最后一个错误.我只需要为我遇到麻烦的每个依赖添加,并使用apt-get install -t testing进行安装.谢谢所有回复的人.你们都非常乐于助人.

小智 8

您可以在Stack Overflow Unix页面中找到类似内容要在debian上安装最新的g ++,请执行以下操作:通过在/etc/apt/sources.list.d文件夹中创建包含以下内容的文件,将debian测试仓库添加到apt源:线

deb http://ftp.us.debian.org/debian testing main contrib non-free
Run Code Online (Sandbox Code Playgroud)

通过在/etc/apt/preferences.d上创建包含以下内容的文件,指示debian在某些包上使用测试源:

Package: *
Pin: release a=testing
Pin-Priority: 100
Run Code Online (Sandbox Code Playgroud)

您应该将文件命名为首选项或testingpref等.如果您有首选项文件,则可以将其添加到该文件中.删除.unused或任何.在文件名中.

更新数据库:

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

安装g ++:

sudo apt-get install -t testing g++
Run Code Online (Sandbox Code Playgroud)

这将为您提供repo中最新版本的g ++.因此,它将接收更新,并且更容易可逆.您需要使用-t测试来获取最新版本.您可能有依赖性问题.它可能是实验性的,而不是测试您的架构.请参阅https://packages.debian.org/search?keywords=g%2B%2B

对于实验包(7在那里)添加:

deb http://httpredir.debian.org/debian experimental main
Run Code Online (Sandbox Code Playgroud)

到/etc/apt/sources.list.与上面类似..钉扎应该说a =实验而不是a =测试,最后,

sudo apt-get install -t experimental g++
Run Code Online (Sandbox Code Playgroud)

祝好运.

  • 想要在Debian 9 Stretch上安装GCC-7(适用于C++ 17)时遇到了这个答案.GCC-7现在正在测试中.感谢非常明确的指示. (7认同)

Die*_*Epp 5

内核无关紧要。

GCC 7 尚未发布,您可以在GCC 7 发行说明中看到:

免责声明:GCC 7 还没有发布,所以这个文档还在开发中。

您可能想了解是什么让不同的 Linux 发行版有所不同。特别是,滚动发行版是什么,以及Debian 发行版是如何工作的。在滚动发行版中,所有软件包都会不断更新到较新的版本。Debian 8.7 (Jessie / stable)不是滚动发行版。软件包版本被冻结,仅在必要时更新,以提高稳定性。Debian 8.7 上 GCC 的最新版本是 GCC 4.9。

Debian 9.0 (Stretch / testing)一个滚动版本,至少在它被冻结之前是这样。如果您将计算机切换到 Stretch,您将获得 GCC 6.3。

如果您需要更新的东西,您可以切换到 Sid(不稳定),或从 Sid 引脚封装。

但是,GCC 7仅在实验阶段可用,因为它尚未发布。如果您愿意,您可以从实验中安装单个软件包,请参阅Debian 实验以获取说明。

如何

添加到您的 /etc/apt/sources.list

https://wiki.debian.org/DebianExperimental
Run Code Online (Sandbox Code Playgroud)

然后

apt-get update
apt-get -t experimental install gcc-7
Run Code Online (Sandbox Code Playgroud)