5

I have set up a cross-compile docker instance. In a nutshell I started setting up the

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

During this last step, I get the following error:

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.

Installing these manually is not an option, since libc6:armhf conflicts with the currently installed amd64 libc6 and will end up overwriting this package. I just want to set-up the libudev:armhf package such that I can link to it.

/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

Running apt-cache policy libudev-dev:{amd64,armhf} outputs the following:

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
psiphi75
  • 946
  • 1
  • 13
  • 25

3 Answers3

6

Step 1 - Open terminal:

Press Ctrl+Alt+T.

Step 2 - Backup:

Execute:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.old

Step 3 - Open the editor:

Execute:

sudo gedit /etc/apt/sources.list

You can use other editors if you want.

Step 4 - Edit sources.list:

Remove everything here and add these:

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

Save and exit.

Step 5 - Update your repository index:

Execute:

sudo apt update

Step 6 - Install libudev-dev for armhf architecture:

Execute:

sudo apt install libudev-dev:armhf

Clarification: Multiarch packages need to be installed with the same version on all architectures. So, you should have libudev-dev:armhf with version 229-4ubuntu21.4, but your current repository configuration does not include this version. So, you should add the line with xenial-updates where this version is supported.

About other suggested to add channels, I suggested you add these in case something goes wrong.

Olimjon
  • 7,292
  • Awesome, that worked! Thanks! The key was in your clarification comment. – psiphi75 Aug 09 '18 at 02:08
  • Why do you need to edit the sources.list file manually? I am trying to cross-compile for the first time, and holy moly Ubuntu has to be the worst system that ever existed for this. – tristan957 Nov 18 '21 at 19:42
0

I tried the steps, however still facing the same error

     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

Config.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"

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Tejas Lotlikar Oct 12 '22 at 08:33
  • @Ankit Kumar, this is a question, you should ask it yourself and refer to the answer given here saying it doesn't work for you. – pbhj Oct 12 '22 at 10:20
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review – pbhj Oct 12 '22 at 10:21
0

For Ubuntu 22.04 I followed @Olimjon 's answer, but changed the following:

Step 1: edit the file

sudo gedit /etc/apt/sources.list

Step 2: based on the answers here How to use apt-get to download multi-arch library?
insert "[arch=amd64]" after "deb" to all existing entries, so it would retain its original architecture
it should now look like:

...
deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ [???] main restricted universe multiverse
...

[???] will depend on your Ubuntu version.

Step 3: add at the bottom, but replace [???] with what you have in Step 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

I tried for [???], xenial, focal, kinetic etc. from other questions, not knowing what it means.
It should be the "codename" for the Ubuntu version you are using.
In my case it's jammy for 22.04 LTS, so mine is:

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

Step 4: run in terminal

sudo apt update

Step 5: install the package you need

sudo apt install libudev-dev:armhf

Note: These steps also solved problems similar to these:
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

Note: I also had, based on this: 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

It might not apply for cross-compilation, but I had it when everything first worked. I removed these lines and reinstalled some packages and it still works.

Note: to add architecture

sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf # 32-bit arm
Ian
  • 101