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

在amd64架构Ubuntu 22.04.1上安装libglib2.0-dev:arm64报错求助

问题描述

在Ubuntu 22.04.1(amd64架构)机器上,为满足交叉编译需求,尝试安装arm64版本的libglib2.0-dev。已配置amd64和arm64双架构仓库,但执行命令sudo apt-get install libglib2.0-dev:arm64时出现如下依赖错误:

The following packages have unmet dependencies:
 libglib2.0-bin:arm64 : Depends: libglib2.0-0:arm64 (= 2.64.6-1~ubuntu20.04.4) but it is not going to be installed
                        Depends: libc6:arm64 (>= 2.17) but it is not installable
                        Depends: libelf1:arm64 (>= 0.142) but it is not going to be installed
 libglib2.0-dev:arm64 : Depends: libffi-dev:arm64 (>= 3.3) but it is not going to be installed
                        Depends: libglib2.0-0:arm64 (= 2.64.6-1~ubuntu20.04.4) but it is not going to be installed
                        Depends: libmount-dev:arm64 (>= 2.28) but it is not going to be installed
                        Depends: libpcre3-dev:arm64 (>= 1:8.31) but it is not going to be installed
                        Depends: libselinux1-dev:arm64 but it is not going to be installed
                        Depends: zlib1g-dev:arm64 but it is not going to be installed
 libglib2.0-dev-bin:arm64 : Depends: libc6:arm64 (>= 2.28) but it is not installable
                            Depends: libglib2.0-0:arm64 (>= 2.39.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
解决方法

1. 确认架构配置与仓库源正确性

  • 检查是否已启用arm64架构:
    dpkg --print-foreign-architectures
    
    若输出无arm64,执行以下命令添加:
    sudo dpkg --add-architecture arm64
    
  • 检查apt源配置,确保所有deb/deb-src条目同时支持amd64和arm64,且对应Ubuntu 22.04(jammy)版本。编辑/etc/apt/sources.list,将源行修改为类似格式:
    deb [arch=amd64,arm64] http://archive.ubuntu.com/ubuntu jammy main restricted
    deb [arch=amd64,arm64] http://archive.ubuntu.com/ubuntu jammy-updates main restricted
    
    注意:错误中出现Ubuntu 20.04(focal)版本的包,说明源配置可能混入旧版本仓库,需彻底清理这类错误条目。

2. 更新源并修复基础依赖

  • 更新apt缓存:
    sudo apt update
    
  • 优先安装核心依赖包:
    sudo apt install libc6:arm64 libglib2.0-0:arm64 libelf1:arm64
    

3. 使用aptitude处理复杂依赖

若apt无法自动解决冲突,安装aptitude工具(它对依赖问题的处理更灵活):

sudo apt install aptitude

再执行目标包安装:

sudo aptitude install libglib2.0-dev:arm64

aptitude会列出可选解决方案,选择编号对应的可行方案(通常选第一个能满足需求的选项),按提示完成操作即可。

4. 解除锁定的损坏包

检查是否存在被锁定(held)的包:

dpkg --get-selections | grep hold

若有输出,解除对应包的锁定:

sudo apt-mark unhold <package-name>

之后重新尝试安装目标包。

内容的提问来源于stack exchange,提问作者Simon Rex

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 01:55:34