Ubuntu – Cross-compile for armhf and install a static library

armcompilingcross-compilation

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

Best Answer

  • 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.

  • Related Question