我正在尝试编译使用 glib.h 的代码。我在互联网上发现软件包 libglib2.0-dev 包含它。但我无法安装它。
这是我的控制台输出:
> sudo apt-get install libglib2.0-dev
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:
libglib2.0-dev : Depends: libglib2.0-0 (= 2.48.0-1ubuntu4) but 2.48.2-0ubuntu1 is to be installed
Depends: libglib2.0-bin (= 2.48.0-1ubuntu4)
E: Unable to correct problems, you have held broken packages.
从能力角度来说:
> sudo aptitude install libglib2.0-dev
The following NEW packages will be installed:
libelf1:i386{a} libffi6:i386{a} libglib2.0-0:i386{ab}
libglib2.0-bin:i386{ab} libglib2.0-dev{b} libpcre3:i386{a}
libpcre3-dev{a} libpcre32-3{a} libpcrecpp0v5{a} libselinux1:i386{a}
zlib1g:i386{a}
0 packages upgraded, 11 newly installed, 0 to remove and 1 not upgraded.
Need to get 3680 kB of archives. After unpacking 21,9 MB will be used.
The following packages have unmet dependencies:
libglib2.0-bin : Conflicts: libglib2.0-bin:i386 but 2.48.0-1ubuntu4 is to be installed.
libglib2.0-bin:i386 : Conflicts: libglib2.0-bin but 2.48.2-0ubuntu1 is installed.
libglib2.0-dev : Depends: libglib2.0-0 (= 2.48.0-1ubuntu4) but 2.48.2-0ubuntu1 is installed.
libglib2.0-0 : Breaks: libglib2.0-0:i386 (!= 2.48.2-0ubuntu1) but 2.48.0-1ubuntu4 is to be installed.
libglib2.0-0:i386 : Breaks: libglib2.0-0 (!= 2.48.0-1ubuntu4) but 2.48.2-0ubuntu1 is installed.
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libglib2.0-0:i386 [Not Installed]
2) libglib2.0-bin:i386 [Not Installed]
3) libglib2.0-dev [Not Installed]
Accept this solution? [Y/n/q/?]
当我输入“y”时,它什么也没做。当我选择“n”时,它建议我卸载大约 1000 个软件包。
> apt policy libglib2.0-dev libglib2.0-0 libglib2.0-bin
libglib2.0-dev:
Installed: (none)
Candidate: 2.48.0-1ubuntu4
Version table:
2.48.0-1ubuntu4 500
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libglib2.0-0:
Installed: 2.48.2-0ubuntu1
Candidate: 2.48.2-0ubuntu1
Version table:
*** 2.48.2-0ubuntu1 100
100 /var/lib/dpkg/status
2.48.0-1ubuntu4 500
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libglib2.0-bin:
Installed: 2.48.2-0ubuntu1
Candidate: 2.48.2-0ubuntu1
Version table:
*** 2.48.2-0ubuntu1 100
100 /var/lib/dpkg/status
2.48.0-1ubuntu4 500
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
Apt 更新输出:
> sudo apt update
Hit:1 http://pl.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://pl.archive.ubuntu.com/ubuntu xenial-updates InRelease
Ign:3 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:4 http://pl.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:5 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:6 http://ppa.launchpad.net/embrosyn/cinnamon/ubuntu xenial InRelease
Get:7 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:8 http://dl.google.com/linux/chrome/deb stable Release
Hit:9 http://ppa.launchpad.net/nathan-renniewaldock/flux/ubuntu xenial InRelease
Hit:10 http://ppa.launchpad.net/noobslab/themes/ubuntu xenial InRelease
Hit:11 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial InRelease
Fetched 102 kB in 0s (129 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
> sudo apt list --upgradable
Listing... Done
qemu/xenial-updates,xenial-security 1:2.5+dfsg-5ubuntu10.14 amd64 [upgradable from: 1:2.5+dfsg-5ubuntu10.10]
N: There are 2 additional versions. Please use the '-a' switch to see them.
我不知道如何获得这个包裹。
答案1
第一步您应该使用以下命令删除2.48.2-0ubuntu1
版本:libglib2.0-0
sudo dpkg -r --force-all libglib2.0-0
之后你应该安装libglib2.0-0
并修复损坏的软件包:
sudo apt update
sudo apt install -f
sudo apt install libglib2.0-0
最后你可以安装:
sudo apt install libglib2.0-dev
答案2
无论你从哪里(可能是你曾经安装过的 PPA)缓存了软件包文件并将其libglib2.0-0
保存libglib2.0-bin
在本地。这些软件包文件比当前官方存储库中的版本更新,并且与官方存储库不兼容。
要清空本地包缓存并阻止安装这些缓存的包,您可以选择(不是绝对必要的,也可能不如预期那么有效)运行
sudo apt clean
此后,或者作为唯一步骤,您可以手动告诉apt
安装的版本:
sudo apt install libglib2.0-dev libglib2.0-0=2.48.0-1ubuntu4 libglib2.0-bin=2.48.0-1ubuntu4