$ sudo apt-get install libsdl2-dev
Reading package lists... Done
Building dependency tree... Done
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:
libpulse-dev : Depends: libpulse0 (= 1:15.99.1+dfsg1-1ubuntu1) but 1:15.99.1+dfsg1-1ubuntu2.1 is to be installed
Depends: libpulse-mainloop-glib0 (= 1:15.99.1+dfsg1-1ubuntu1) but 1:15.99.1+dfsg1-1ubuntu2.1 is to be installed
libudev-dev : Depends: libudev1 (= 249.11-0ubuntu3.7) but 249.11-0ubuntu3.11 is to be installed
E: Unable to correct problems, you have held broken packages.
aptitude
工具# 先安装工具 aptitude
$ sudo aptitude install aptitude
aptitude
工具手动解决部分依赖关系# 使用aptitude再次执行安装, 先安装上面依赖的一个库
$ sudo aptitude install libudev-dev
The following NEW packages will be installed:
libudev-dev{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.7 kB of archives. After unpacking 270 kB will be used.
The following packages have unmet dependencies:
libudev-dev : Depends: libudev1 (= 249.11-0ubuntu3.7) but 249.11-0ubuntu3.11 is installed
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libudev-dev [Not Installed]
# 注意下面这行, 选择 `n` 否决上面的 不安装方案, 让工具提示其他方案;
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:
Remove the following packages:
1) udev [249.11-0ubuntu3.11 (now)]
Install the following packages:
2) gcc-12-base:i386 [12.3.0-1ubuntu1~22.04 (jammy-security)]
3) krb5-locales [1.19.2-2ubuntu0.3 (jammy-security)]
4) libacl1:i386 [2.3.1-1 (jammy)]
5) libblkid1:i386 [2.37.2-4ubuntu3 (jammy)]
6) libc6:i386 [2.35-0ubuntu3.6 (jammy-security)]
7) libcap2:i386 [1:2.44-1ubuntu0.22.04.1 (jammy-security)]
8) libcom-err2:i386 [1.46.5-2ubuntu1.1 (jammy-security)]
9) libcrypt1:i386 [1:4.4.27-1 (jammy)]
10) libgcc-s1:i386 [12.3.0-1ubuntu1~22.04 (jammy-security)]
11) libgssapi-krb5-2:i386 [1.19.2-2ubuntu0.3 (jammy-security)]
12) libidn2-0:i386 [2.3.2-2build1 (jammy)]
13) libk5crypto3:i386 [1.19.2-2ubuntu0.3 (jammy-security)]
14) libkeyutils1:i386 [1.6.1-2ubuntu3 (jammy)]
15) libkmod2:i386 [29-1ubuntu1 (jammy)]
16) libkrb5-3:i386 [1.19.2-2ubuntu0.3 (jammy-security)]
17) libkrb5support0:i386 [1.19.2-2ubuntu0.3 (jammy-security)]
18) liblzma5:i386 [5.2.5-2ubuntu1 (jammy)]
19) libnsl2:i386 [1.3.0-2build2 (jammy)]
20) libnss-nis:i386 [3.1-0ubuntu6 (jammy)]
21) libnss-nisplus:i386 [1.3-0ubuntu6 (jammy)]
22) libpcre2-8-0:i386 [10.39-3ubuntu0.1 (jammy-security)]
23) libselinux1:i386 [3.3-1build2 (jammy)]
24) libssl3:i386 [3.0.2-0ubuntu1.12 (jammy-security)]
25) libtirpc3:i386 [1.3.2-2ubuntu0.1 (jammy-security)]
26) libudev1:i386 [249.11-0ubuntu3.7 (jammy-security)]
27) libunistring2:i386 [1.0-1 (jammy)]
28) libzstd1:i386 [1.4.8+dfsg-3build1 (jammy)]
29) udev:i386 [249.11-0ubuntu3.7 (jammy-security)]
Downgrade the following packages:
30) libudev1 [249.11-0ubuntu3.11 (now) -> 249.11-0ubuntu3.7 (jammy-security)
Leave the following dependencies unresolved:
31) udev:i386 recommends systemd-hwe-hwdb:i386
# 这里选择方案29或者30看起来都是安装 249.11-0ubuntu3.7 这个版本;
Accept this solution? [Y/n/q/?] 30
Action "30": Installing libudev1 249.11-0ubuntu3.7 (jammy-security)
Package: libudev1
Version: 249.11-0ubuntu3.7
State: installed (249.11-0ubuntu3.11), upgrade available (249.11-0ubuntu3.7)
Automatically installed: no
Multi-Arch: same
Priority: required
Section: libs
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Uncompressed Size: 354 k
Depends: libc6 (>= 2.34)
Breaks: libudev1:i386 (!= 249.11-0ubuntu3.7)
Replaces: libudev1:i386 (< 249.11-0ubuntu3.7)
Description: libudev shared library
This library provides access to udev device information.
Homepage: https://www.freedesktop.org/wiki/Software/systemd
This action was selected because libudev-dev depends upon libudev1 (=
249.11-0ubuntu3.7).
Enter "r 30" to prevent this action from appearing in new solutions.
Enter "a 30" to require that new solutions include this action if possible.
# 后面就是一路敲回车自动处理了;
Accept this solution? [Y/n/q/?]
The following packages will be DOWNGRADED:
libudev1
The following NEW packages will be installed:
gcc-12-base:i386{a} krb5-locales{a} libacl1:i386{a} libblkid1:i386{a}
libc6:i386{a} libcap2:i386{a} libcom-err2:i386{a} libcrypt1:i386{a}
libgcc-s1:i386{a} libgssapi-krb5-2:i386{a} libidn2-0:i386{a}
libk5crypto3:i386{a} libkeyutils1:i386{a} libkmod2:i386{a}
libkrb5-3:i386{a} libkrb5support0:i386{a} liblzma5:i386{a}
libnsl2:i386{a} libnss-nis:i386{a} libnss-nisplus:i386{a}
libpcre2-8-0:i386{a} libselinux1:i386{a} libssl3:i386{a}
libtirpc3:i386{a} libudev-dev libudev1:i386{a} libunistring2:i386{a}
libzstd1:i386{a} udev:i386{a}
The following packages will be REMOVED:
systemd-hwe-hwdb{u} udev{a}
0 packages upgraded, 29 newly installed, 1 downgraded, 2 to remove and 0 not upgraded.
Need to get 9,395 kB of archives. After unpacking 27.9 MB will be used.
Do you want to continue? [Y/n/?]
Get: 1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security/main i386 gcc-12-base i386 12.3.0-1ubuntu1~22.04 [20.1 kB]
$ sudo apt-get install libsdl2-dev
Reading package lists... Done
Building dependency tree... Done
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:
libpulse-dev : Depends: libpulse0 (= 1:15.99.1+dfsg1-1ubuntu1) but 1:15.99.1+dfsg1-1ubuntu2.1 is to be installed
Depends: libpulse-mainloop-glib0 (= 1:15.99.1+dfsg1-1ubuntu1) but 1:15.99.1+dfsg1-1ubuntu2.1 is to be installed
E: Unable to correct problems, you have held broken packages.
1:15.99.1+dfsg1-1ubuntu1
这个版本, 但是安装了较新的另一个版本 1:15.99.1+dfsg1-1ubuntu2.1
, 看来还是要做一次降级;aptitude
工具解决剩余的依赖, 降级到合适的版本即可;$ sudo aptitude install libsdl2-dev
The following NEW packages will be installed:
libasound2-dev{a} libblkid-dev{a} libdbus-1-dev{a} libdecor-0-0{a} libdecor-0-plugin-1-cairo{a} libegl-dev{a} libegl1-mesa-dev{a} libgl-dev{a} libgles-dev{a} libgles1{a} libglib2.0-dev{a}
libglib2.0-dev-bin{a} libglu1-mesa-dev{a} libglvnd-core-dev{a} libglvnd-dev{a} libglx-dev{a} libibus-1.0-dev{a} libice-dev{a} libmount-dev{a} libopengl-dev{a} libpcre16-3{a} libpcre2-dev{a}
libpcre2-posix3{a} libpcre3-dev{a} libpcre32-3{a} libpcrecpp0v5{a} libpthread-stubs0-dev{a} libsdl2-2.0-0{a} libsdl2-dev{b} libselinux1-dev{a} libsepol-dev{a} libsm-dev{a} libsndio-dev{a}
libwayland-bin{a} libwayland-dev{a} libx11-dev{a} libxau-dev{a} libxcb1-dev{a} libxcursor-dev{a} libxdmcp-dev{a} libxext-dev{a} libxfixes-dev{a} libxi-dev{a} libxinerama-dev{a} libxkbcommon-dev{a}
libxrandr-dev{a} libxrender-dev{a} libxss-dev{a} libxt-dev{a} libxv-dev{a} libxxf86vm-dev{a} uuid-dev{a} x11proto-dev{a} xorg-sgml-doctools{a} xtrans-dev{a}
0 packages upgraded, 55 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.2 MB of archives. After unpacking 50.7 MB will be used.
The following packages have unmet dependencies:
libsdl2-dev : Depends: libpulse-dev but it is not installable
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libsdl2-dev [Not Installed]
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:
Install the following packages:
1) libpulse-dev [1:15.99.1+dfsg1-1ubuntu1 (jammy)]
Downgrade the following packages:
2) libpulse-mainloop-glib0 [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
3) libpulse0 [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
4) libpulsedsp [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
5) pulseaudio [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
6) pulseaudio-module-bluetooth [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
7) pulseaudio-module-gsettings [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
8) pulseaudio-utils [1:15.99.1+dfsg1-1ubuntu2.1 (now) -> 1:15.99.1+dfsg1-1ubuntu1 (jammy)]
Accept this solution? [Y/n/q/?] 1
Action "1": Installing libpulse-dev 1:15.99.1+dfsg1-1ubuntu1 (jammy)
Package: libpulse-dev
Version: 1:15.99.1+dfsg1-1ubuntu1
State: not installed
Multi-Arch: same
Priority: optional
Section: libdevel
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Uncompressed Size: 557 k
Depends: libpulse0 (= 1:15.99.1+dfsg1-1ubuntu1), libpulse-mainloop-glib0 (= 1:15.99.1+dfsg1-1ubuntu1), libglib2.0-dev
Breaks: libpulse-dev:i386 (!= 1:15.99.1+dfsg1-1ubuntu1)
Replaces: libpulse-dev:i386 (< 1:15.99.1+dfsg1-1ubuntu1)
Description: PulseAudio client development headers and libraries
PulseAudio, previously known as Polypaudio, is a sound server for POSIX and WIN32 systems. It is a drop in replacement for the ESD sound server with much better latency, mixing/re-sampling quality and
overall architecture.
Headers and libraries for developing applications that access a PulseAudio sound server via PulseAudio's native interface.
Homepage: http://www.pulseaudio.org
This action was selected because libsdl2-dev depends upon libpulse-dev.
Enter "r 1" to prevent this action from appearing in new solutions.
Enter "a 1" to require that new solutions include this action if possible.
Accept this solution? [Y/n/q/?]
The following packages will be DOWNGRADED:
libpulse-mainloop-glib0 libpulse0 libpulsedsp pulseaudio pulseaudio-module-bluetooth pulseaudio-module-gsettings pulseaudio-utils
The following NEW packages will be installed:
libsdl2-dev
已经成功安装$ sudo aptitude install libsdl2-dev
libsdl2-dev is already installed at the requested version (2.0.20+dfsg-2build1)
libsdl2-dev is already installed at the requested version (2.0.20+dfsg-2build1)
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
如果直接自动修复能解决, 那就解决, 如果是类似于本文的, 已经安装了较新版本的, 一般都要仔细观察, 然后对已安装的进行版本降级处理才行哟;
sudo apt-get -f install
sudo apt-get update
sudo apt-get upgrade
sudo apt-get update
sudo apt-get clean
sudo apt-get autoremove
sudo apt --fix-broken install
sudo apt-get update && sudo apt-get upgrade
sudo dpkg --configure -a
sudo apt-get install -f