You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04安装libdrm-dev时依赖版本不兼容问题求助

Ubuntu 20.04安装libdrm-dev时依赖版本不兼容问题求助

嘿,看起来你在Ubuntu 20.04上装libdrm-dev时碰到了版本依赖的坑——系统里已经更新到了更高版本的libdrm相关库,但dev包却死磕旧版本,这确实挺闹心的。我来给你捋捋可能的原因和解决办法:

先看看你遇到的具体报错情况:

执行sudo apt install libdrm-dev时的错误输出:

$ sudo apt install libdrm-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:

libdrm-dev : Depends: libdrm2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
Depends: libdrm-intel1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
Depends: libdrm-radeon1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
Depends: libdrm-nouveau2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
Depends: libdrm-amdgpu1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed

E: Unable to correct problems, you have held broken packages.

用aptitude检查后也确认了版本不匹配:

$ sudo aptitude install libdrm-dev

The following NEW packages will be installed:
libdrm-dev{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 126 kB of archives. After unpacking 658 kB will be used.

The following packages have unmet dependencies:
libdrm-dev : Depends: libdrm2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
Depends: libdrm-intel1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
Depends: libdrm-radeon1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
Depends: libdrm-nouveau2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
Depends: libdrm-amdgpu1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed

The following actions will resolve these dependencies:

Keep the following packages at their current version:
1)     libdrm-dev [Not Installed]

Accept this solution? [Y/n/q/?]

几个可行的解决方向:

  • 先检查软件源是否完整
    你的系统里的libdrm库是2.4.107-8ubuntu1~20.04.2,这是Ubuntu 20.04的更新版本,通常来自focal-updates或focal-security仓库。如果libdrm-dev找不到对应版本,大概率是你没启用这些更新源。
    打开/etc/apt/sources.list文件,确保里面有类似这些条目:

    deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
    

    保存后执行sudo apt update刷新源,再试试安装libdrm-dev。

  • 直接指定版本安装dev包
    既然你已经有了2.4.107-8ubuntu1~20.04.2版本的运行库,那对应的dev包也应该是同一版本。直接指定版本安装试试:

    sudo apt install libdrm-dev=2.4.107-8ubuntu1~20.04.2
    

    如果apt提示找不到这个版本,那可以手动下载对应架构的deb包,然后用sudo dpkg -i 下载的包路径.deb安装。

  • 别轻易用强制安装
    千万不要尝试--force-yes这类强制选项,dev包必须和运行库版本完全匹配,强制安装会破坏依赖链,后续编译程序或更新软件都会出问题。

  • 检查是否有被固定的包
    错误里提到“held broken packages”,你可以用下面的命令看看有没有被固定版本的libdrm相关包:

    sudo apt-mark showhold
    

    如果有,执行sudo apt-mark unhold 包名解除固定,再重新尝试安装。

备注:内容来源于stack exchange,提问作者Gabriel Staples

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 12:33:01