Ubuntu (Xenial): How to force apt-get install libssl-dev:arm64 and armhf so I can cross-compile against pre-built libs

Asked by Matthew Giassa

================================================================================
Goal
================================================================================

I am attempting to configure a multi-arch build system to build armhf, arm64, i386/x86, and amd64/x64 builds of a Linux project of mine. I already have the necessary tools in place in my Makefile, along with the following toolchains which I installed via apt-get:

    arm-linux-gnueabi-g++
    arm-linux-gnueabi-gcc
    aarch64-linux-gnu-g++
    aarch64-linux-gnu-gcc

================================================================================
Details
================================================================================

I am able to build my projects successfully, but there's a caveat: I had to prebuild a ton of dependencies in advance, including gtkmm, gtkmm-dev, glademm, cairo, etc, so get the GUI components of my project supported on all 4 build variants. I'm trying to find a way to pull all these dependencies from the pre-built archives for Xenial (Ubuntu 16.04 LTS) for the arm64 and armhf architectures.

From reading a separate post, I found out that I can pull complete .deb packages from the apt-get repos using aptitude, but this only solves part of my problem. On my Xenial 64-bit system, I can install x86 compatibility libraries so I can cross compile for 32-bit systems easily enough, by:

    Pulling the x86 version of a library (ie: for libssl-dev, I issue: sudo apt-get install libss-devl:i386).
    Specify building against x86 by adding: CFLAGS+=-m32.

================================================================================
Issue
================================================================================

For the latter of these two steps, I just use the appropriate cross-compiler: easy enough. For pulling the appropriate packages though, something like sudo apt-get install libssl-dev:arm64 or sudo apt-get install libssl-dev:armhf fails. I've also tried using `sudo dpkg --add-architecture arm64`, but apt-get update fails afterwards, since the apt repos do not have an arm64/armhf directory structure like the LaunchPad repos (ie: https://launchpad.net/ubuntu/xenial/arm64 and https://launchpad.net/ubuntu/xenial/armhf).

================================================================================
Question
================================================================================

How can I pull development libraries and make them available for the cross-compilers on my system? There are two ways I can think of:

    Install the arm64/armhf variants, if possible, via apt-get. I think the command I'm using is wrong, or I need to make some changes to my /etc/apt/sources.list file and enable some additional multi-arch settings.
    Just download the .deb files using aptitude, and extract them to a local folder, and explicitly pass the folder path in my Makefile.

Unfortunately, I don't know how to do either of these steps, or there may be a hidden third option that's better which I'm unaware of.

How can I accomplish this goal of mine? It sounds like it would be far less hassle than manually building all the dependencies myself.

Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Matthew Giassa (mgiassa) said :
#1

Found an article with an alternative approach (ie: a batch of QEMU VMs using official Ubuntu binary images) if cross-compiling isn't viable (http://webkit.sed.hu/blog/20140816/quickndirty-set-aarch64-ubuntu-1404-vm-qemu).

Apparently pkg-config wouldn't suite my current needs anyway (https://www.freedesktop.org/wiki/Software/pkg-config/CrossCompileProposal/), so this question might not have a practical answer.

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#2

You might try modifying your sources.list files like this:

deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
deb [arch=i386,amd64] http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
deb [arch=arm64,armhf,powerpc] http://ports.ubuntu.com/ xenial main restricted universe multiverse
deb [arch=arm64,armhf,powerpc] http://ports.ubuntu.com/ xenial-security main restricted universe multiverse
deb [arch=arm64,armhf,powerpc] http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
deb-src http://ports.ubuntu.com/ xenial main restricted universe multiverse
deb-src http://ports.ubuntu.com/ xenial-security main restricted universe multiverse
deb-src http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse

This should allow apt-get to function.

Revision history for this message
Matthew Giassa (mgiassa) said :
#3

The above suggestions worked in general, but the problem is that some of the packages I had to install have issues where there are files unique to each package that get deployed to a common OS-independent location via apt, so only one architecture can be installed at once. This is a bug in the individual packages, IMHO, and not the suggestion you provided. Thank you.

Revision history for this message
Matthew Giassa (mgiassa) said :
#4

Thanks Manfred Hampl, that solved my question.

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

If two architectures want to install the __same__ file (e.g. README or changelog), but have not been correctly defined and packaged, you might try forcing the installation with a command like

sudo apt-get -o Dpkg::Options::="--force-overwrite" install package:arch

(This of course does not help if the files really differ between architectures.)

Revision history for this message
Matthew Giassa (mgiassa) said :
#6

Thank you for this information Manfred.

============================================================
Matthew Giassa, MASc, BASc, EIT
Security and Embedded Systems Specialist
linkedin: https://ca.linkedin.com/in/giassa
e-mail: <email address hidden>
website: www.giassa.net

> -------- Original Message --------
> Subject: Re: [Question #293624]: Ubuntu (Xenial): How to force apt-get
> install libssl-dev:arm64 and armhf so I can cross-compile against
> pre-built libs
> From: Manfred Hampl <email address hidden>
> Date: Wed, May 25, 2016 9:22 am
> To: <email address hidden>
>
>
> Your question #293624 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/293624
>
> Manfred Hampl posted a new comment:
> If two architectures want to install the __same__ file (e.g. README or
> changelog), but have not been correctly defined and packaged, you might
> try forcing the installation with a command like
>
> sudo apt-get -o Dpkg::Options::="--force-overwrite" install package:arch
>
> (This of course does not help if the files really differ between
> architectures.)
>
> --
> You received this question notification because you asked the question.