sudo apt-get安装libstdc ++


16

当我尝试libstdc++使用安装时:

sudo apt-get install libstdc++

我在ubuntu中收到以下错误。你有什么想法吗?

The following packages have unmet dependencies:
 libstdc++-4.8-doc : Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                     Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
                     Conflicts: libstdc++6-4.7-doc but 4.7.3-12ubuntu1 is to be installed
 libstdc++-4.9-doc : Conflicts: libstdc++-4.8-doc but 4.8.5-2ubuntu1~14.04.1 is to be installed
                     Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                     Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
                     Conflicts: libstdc++6-4.7-doc but 4.7.3-12ubuntu1 is to be installed
 libstdc++-5-doc : Conflicts: libstdc++-4.8-doc but 4.8.5-2ubuntu1~14.04.1 is to be installed
                   Conflicts: libstdc++-4.9-doc but 4.9.3-8ubuntu2~14.04 is to be installed
                   Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                   Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
                   Conflicts: libstdc++6-4.7-doc but 4.7.3-12ubuntu1 is to be installed
 libstdc++6-4.6-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
 libstdc++6-4.6-doc : Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
 libstdc++6-4.7-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
 libstdc++6-4.7-doc : Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
 libstdc++6-4.8-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
                      Conflicts: libstdc++6-4.7-dbg but 4.7.3-12ubuntu1 is to be installed
 libstdc++6-4.8-dbg-armhf-cross : Conflicts: libstdc++6-4.7-dbg-armhf-cross but 4.7.3-11ubuntu1cross1.85 is to be installed
 libstdc++6-4.9-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
                      Conflicts: libstdc++6-4.7-dbg but 4.7.3-12ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.8-dbg but 4.8.5-2ubuntu1~14.04.1 is to be installed
 libstdc++6-5-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                    Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
                    Conflicts: libstdc++6-4.7-dbg but 4.7.3-12ubuntu1 is to be installed
                    Conflicts: libstdc++6-4.8-dbg but 4.8.5-2ubuntu1~14.04.1 is to be installed
                    Conflicts: libstdc++6-4.9-dbg but 4.9.3-8ubuntu2~14.04 is to be installed
E: Unable to correct problems, you have held broken packages.

您最近添加了任何PPA吗?
拉斐尔

1
这里实际上不是叫包libstdc++(可能是你正在尝试安装libstdc++6呢?因为的++字符,时apt没有找到完全匹配它把包名作为正则表达式所以在这种情况下,它正试图安装任何程序包,其名称比赛libstd后跟着一个或多个c-如您所见,其中有许多冲突
。– steeldriver

@steeldriver:这显然是答案,恕我直言应该是答案而不是评论(尽管这将有助于解释如何避免将字符串视为正则表达式)。对于手册页apt说,它将把包名作为正则表达式,如果它们包括.?*不提+,这样的行为是不完全的预期。
rici

Answers:


12

实际上没有一个名为的软件包libstdc++(可能您正在尝试安装libstdc++6?)

当apt找不到与软件包名称完全匹配的名称时,它将给定的字符串视为正则表达式。在这种情况下,++导致尝试安装名称匹配后跟一个或多个的任何软件包-如您所见,其中许多冲突。libstdc

不幸的是,我从来没有想过如何关闭这种行为(我过去使用转义字符尝试过的所有方法似乎都没有用)-我知道的唯一解决方案是小心给出任何正则表达式字符的确切包名称。可能会被误解,并确保软件包目录是最新的,即

sudo apt-get update
sudo apt-get install libstdc++6

这应该被接受。关于关闭:可以编写一个别名或函数,将包名包装在一个^PACKAGE$
phil294中,

11

首先运行这些命令

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt-get install aptitude

然后尝试

sudo apt-get install libstdc++6

或尝试此搜索结果并从列出的http://packages.ubuntu.com/search?keywords=libstdc%2B%2B安装一个所需的软件包


2
+1很好的答案,但是s中不libstdc++包括build-essential吗?
凯夫·因斯基

7
哦,aptitude如果不使用它进行安装,为什么还要安装libstdc++6呢?
凯夫·英斯基

2
感谢您的回复。如果没有成功,我会尝试提供一些可能性。并且有能力处理他的错误。
MAK Ripon

sudo apt-get更新apt-get:加载共享库时出错:
usr/lib/x86_64

3
LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9

6
您能否解释一下用户为什么必须这样做以及每个命令的作用?(以防其他人阅读您的答案并决定将其复制粘贴以解决错误的问题?) ;-)
Fabby
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.