最近在Ubuntu16.04上编译opencv,但从最开始就遇到了头大的问题,在下载安装依赖项时遇到Depends:xxx but it is not going to be installed,更可恶的是有时候我这个依赖项明明已经安装了,却依然提醒这个问题。
有些大佬们使用 sudo apt-get -f install xxx来解决,但我这里没用,所以记录下我采用的解决方法。这里感谢该文章中大佬的回复,解决了我的问题。引用了改地址大佬回复 https://www.v2ex.com/t/70636
我用真实遇到的问题记录,比如我使用
sudo apt-get isntall libvtk5-dev
会出现以下错误
The following packages have unmet dependencies:
libvtk5-dev : Depends: libgl1-mesa-dev but it is not going to be installed or
libgl-dev
Depends: libglu1-mesa-dev but it is not going to be installed or
libglu-dev
Depends: libnetcdf-dev but it is not going to be installed
Depends: libnetcdf-cxx-legacy-dev but it is not going to be installed
Depends: libpq-dev but it is not going to be installed
Depends: libtiff-dev
Depends: libvtk5.10 (= 5.10.1+dfsg-2.1build1) but it is not going to be installed
Depends: libxml2-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
随后我按照以下过程解决该问题:
1: sudo apt-get install aptitude
2: sudo aptitude install libvtk5-dev
然后同样会出现一些按照错误,但不影响我们后续安装,如下所示:
The following NEW packages will be installed:
comerr-dev{a} hdf5-helpers{a} i965-va-driver{a} krb5-multidev{ab}
libaacs0{a} libaec-dev{a} libaec0{a} libavcodec-dev{a}
libavcodec-ffmpeg56{a} libavformat-dev{a} libavformat-ffmpeg56{a}
......
libgl1-mesa-dev : Depends: libgl1-mesa-glx (= 11.2.0-1ubuntu2) but 17.2.8-0ubuntu0~16.04.1 is installed.
libdrm-dev : Depends: libdrm2 (= 2.4.67-1) but 2.4.83-1~16.04.1 is installed.
Depends: libdrm-intel1 (= 2.4.67-1) but 2.4.83-1~16.04.1 is installed.
Depends: libdrm-radeon1 (= 2.4.67-1) but 2.4.83-1~16.04.1 is installed.
Depends: libdrm-nouveau2 (= 2.4.67-1) but 2.4.83-1~16.04.1 is installed.
Depends: libdrm-amdgpu1 (= 2.4.67-1) but 2.4.83-1~16.04.1 is installed.
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) krb5-multidev [Not Installed]
2) libcurl4-gnutls-dev [Not Installed]
3) libdrm-dev [Not Installed]
......
19) libvtk5.10 [Not Installed]
20) libx11-xcb-dev [Not Installed]
21) mesa-common-dev [Not Installed]
Leave the following dependencies unresolved:
22) libqt4-dev recommends libqt4-opengl-dev (= 4:4.8.7+dfsg-5ubuntu2)
Accept this solution? [Y/n/q/?]n
由于我这里很多是因为版本不一致造成的,所以很多会显示 [Not Installed],但我在下面输入的是“n”
然后会重新提醒安装需要的版本并选择接受,即“y”
The following actions will resolve these dependencies:
Remove the following packages:
1) clang-8
2) lib32stdc++6
......
31) libubsan0 [5.4.0-6ubuntu1~16.04.12 (now) -> 5.3.1-14ubuntu2 (xenial)]
Accept this solution? [Y/n/q/?] y
然后开始安装,最终解决我的问题。
仅作为个人笔记记录。