我已经设置了一个交叉编译docker实例。简而言之,我开始设置
apt-get update
apt-get install binutils-multiarch
dpkg --add-architecture armhf
# Manually add correct armhf repositories to /etc/apt/sources.list
apt-get update
apt-get install libudev-dev:armhf
在最后一步中,我收到以下错误:
The following packages have unmet dependencies:
libudev-dev:armhf : Depends: libacl1:armhf (>= 2.2.51-8) but it is not going to be installed
Depends: libblkid1:armhf (>= 2.19.1) but it is not going to be installed
Depends: libc6:armhf (>= 2.17) but it is not going to be installed
Depends: libgcc1:armhf (>= 1:3.5) but it is not going to be installed
Depends: libkmod2:armhf (>= 5~) but it is not going to be installed
Depends: libselinux1:armhf (>= 2.0.65) but it is not going to be installed
Depends: libudev1:armhf (= 229-4ubuntu4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
手动安装这些不是一个选项,因为libc6:armhf
它们与当前安装的 amd64 libc6 冲突,最终会覆盖此包。我只想设置包libudev:armhf
以便我可以链接到它。
/etc/apt/sources.list:
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial main restricted
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security multiverse
运行apt-cache policy libudev-dev:{amd64,armhf}
输出以下内容:
libudev-dev:
Installed: (none)
Candidate: 229-4ubuntu21.4
Version table:
229-4ubuntu21.4 500
500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
229-4ubuntu21.1 500
500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
229-4ubuntu4 500
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libudev-dev:armhf:
Installed: (none)
Candidate: 229-4ubuntu4
Version table:
229-4ubuntu4 500
500 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf Packages
答案1
步骤 1-打开终端:
按Ctrl+ Alt+ T。
第 2 步 - 备份:
执行:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
步骤 3——打开编辑器:
执行:
sudo gedit /etc/apt/sources.list
如果您愿意,您可以使用其他编辑器。
步骤 4-编辑sources.list
:
删除此处的所有内容并添加以下内容:
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial main multiverse restricted universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial main multiverse restricted universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial-updates main multiverse restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ xenial-security main multiverse restricted universe
保存并退出。
步骤 5 - 更新您的存储库索引:
执行:
sudo apt update
步骤 6 - 安装libudev-dev
架构armhf
:
执行:
sudo apt install libudev-dev:armhf
澄清:多架构软件包需要在所有架构上安装相同的版本。因此,您应该有libudev-dev:armhf
版本229-4ubuntu21.4
,但您当前的存储库配置不包括此版本。因此,您应该添加xenial-updates
支持此版本的行。
关于其他建议添加的渠道,我建议您添加这些以防出现问题。
答案2
我尝试了这些步骤,但仍然面临同样的错误
Running `rustc --crate-name crossbeam_utils /home/akumar/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.7.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="lazy_static"' --cfg 'feature="std"' -C metadata=c767ae876e08d99c -C extra-filename=-c767ae876e08d99c --out-dir /home/akumar/targetarm/target/armv7-unknown-linux-gnueabihf/release/deps --target armv7-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc -L dependency=/home/akumar/targetarm/target/armv7-unknown-linux-gnueabihf/release/deps -L dependency=/home/akumar/targetarm/target/release/deps --extern cfg_if=/home/akumar/targetarm/target/armv7-unknown-linux-gnueabihf/release/deps/libcfg_if-957f1673fd73ef34.rmeta --extern lazy_static=/home/akumar/targetarm/target/armv7-unknown-linux-gnueabihf/release/deps/liblazy_static-68fcde486f90d4ec.rmeta --cap-lints allow -C target-cpu=cortex-a72 --cfg has_min_const_fn --cfg has_atomic_u8 --cfg has_atomic_u16 --cfg has_atomic_u32 --cfg has_atomic_u64`
error: failed to run custom build command for `libudev-sys v0.1.4`
Caused by:
process didn't exit successfully: `/home/akumar/targetarm/target/release/build/libudev-sys-0463db1d4d4cbd4d/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "pkg-config has not been configured to support cross-compilation.\n\nInstall a sysroot for the target platform and configure it via\nPKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\ncross-compiling wrapper for pkg-config and set it via\nPKG_CONFIG environment variable."', /home/akumar/.cargo/registry/src/github.com-1ecc6299db9ec823/libudev-sys-0.1.4/build.rs:38:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
配置.toml
[target.armv7-unknown-linux-musleabihf]
linker = "armv7-linux-musleabihf-gcc"
rustflags = "-C target-cpu=cortex-a72"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
rustflags = "-C target-cpu=cortex-a72"
答案3
对于 Ubuntu 22.04,我遵循了@Olimjon 的回答,但更改了以下内容:
步骤1:编辑文件
sudo gedit /etc/apt/sources.list
第2步:根据这里的答案如何使用 apt-get 下载多架构库?
在所有现有条目的“deb”后插入“[arch=amd64]”,这样它将保留其原始架构,
现在看起来应该像这样:
...
deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ [???] main restricted universe multiverse
...
[???] 取决于您的 Ubuntu 版本。
步骤3:在底部添加,但将 [???] 替换为步骤 2 中的内容
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???] main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???]-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???] universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???]-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???] multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???]-updates multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ [???]-backports main restricted universe multiverse
我尝试了其他问题中的 [???]、xenial、focal、kinetic 等,但不知道它们是什么意思。
它应该是你正在使用的 Ubuntu 版本的“代号”。
在我的情况下,它是 22.04 LTS 的 jammy,所以我的代号是:
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy-updates multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ jammy-backports main restricted universe multiverse
步骤4:在终端中运行
sudo apt update
步骤5:安装你需要的包
sudo apt install libudev-dev:armhf
笔记:这些步骤也解决了类似的问题:
https://unix.stackexchange.com/questions/329165/installing-libudev-for-arm-on-x64-ubuntu
https://unix.stackexchange.com/questions/608001/having-trouble-with-an-unmet-dependencies-loop-using-apt
笔记:我也有,基于此:https://unix.stackexchange.com/questions/728589/in-depth-explanation-of-components-in-sources-list
deb [arch=armhf,arm64] http://archive.ubuntu.com/ubuntu jammy main universe restricted multiverse
deb [arch=armhf,arm64] http://archive.ubuntu.com/ubuntu jammy-updates main universe restricted multiverse
deb [arch=armhf,arm64] http://archive.ubuntu.com/ubuntu jammy-backports main universe restricted multiverse
它可能不适用于交叉编译,但当一切开始工作时我就用过它。我删除了这些行并重新安装了一些软件包,它仍然有效。
笔记:添加架构
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf # 32-bit arm