0

There is a package I build from source, following this recipe:

echo "deb-src http://archive.ubuntu.com/ubuntu focal main" >> /etc/apt/sources.list
echo "deb-src http://archive.ubuntu.com/ubuntu focal-updates main" >> /etc/apt/sources.list
apt update

apt source package
apt build-dep -y package

cd package/
dpkg-buildpackage

I want to cross-compile this package on an aarch64 host for an amd64 target. What parts might be necessary to modify?

For example, I could start with:

# basically, set up the apt repos for both amd64 and aarch64 
sed -i '/^deb / {p; s/^deb /deb [arch=arm64] /}' /etc/apt/sources.list
sed -i 's,^deb http://ports.ubuntu.com/ubuntu-ports/,deb [arch=amd64] http://archive.ubuntu.com/ubuntu/,' /etc/apt/sources.list

echo "deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu focal main" >> /etc/apt/sources.list
echo "deb-src [arch=amd64] http://archive.ubuntu.com/ubuntu focal-updates main" >> /etc/apt/sources.list
dpkg --add-architecture amd64
apt update

# install the cross compiler
apt install -y gcc-x86-64-linux-gnu

apt source package:amd64
apt build-dep -y package:amd64

cd package/
dpkg-buildpackage --target-arch=amd64

But this seems to be incomplete. For instance, if I am building the Linux kernel, dpkg-buildpackage complains that I'm missing dependencies like libudev-dev, and it invokes make ARCH=arm64 CROSS_COMPILE= which is for the host architecture, not the target.

1 Answer 1

0

Here's an old question on the topic: How to cross-build a Debian package.

tshepang's answer there points out to use dpkg-buildpackage --host-arch=amd64 instead of --target-arch=. This is counterintuitive to me according to the widely used definitions of host and target when cross-compiling, but the nomenclature for Debian is slightly different, and target-arch is only used when building compilers and such.

For instance, if I am building the Linux kernel, dpkg-buildpackage complains that I'm missing dependencies like libudev-dev...

I worked around this with --no-check-builddeps but I haven't gotten to the bottom of why dpkg-buildpackage believes some dependencies are missing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .