Compile a debian package for amd64 on a i386 machine?

I have a i386 ubuntu hardy machine, and an amd64 ubuntu hardy machine. I want to compile a debian package (a.k.a. deb) for the amd64 machine on the i386 (because I don't have enough memory to compile is quickly on the amd64 machine). If I do a dpkg-buildpackage on the i386 machine, it produces a deb for i386, which can't be installed on the amd64 machine. Is there anyway to compile the deb for amd64 on the i386 machine?


So, there are some solutions to that:

  • Setup a cross-compiling toolchain and use regular dpkg-buildpackage to build your package. The problem is that creating a toolchain is not very straightforward.
  • Use a 32 bit chroot on your 64 bit machine to compile stuff. Apparently it's the most recommended method. This blog post has an example of kernel compilation but it's the same process for any other software.

It's probably more trouble than it's worth to try and get cross compiling going. There are various ways to emulate 64 bit systems on 32 bits, but you'll pay a perfomance price.

If you're only doing a bit of this, then I'd say fire up a 64 bit machine on Amazon for a few hours. If you're doing it a lot, then maybe get some 64 bit hardware, or maybe AWS remains interesting, because you only pay for how much you use it, and you can fire up a build farm when you want it.

This might give you some useful ideas: http://blog.fwbuilder.org/2009/05/building-ubuntu-deb-packages-on-amazon.html

This list of images of debian systems for various architectures and releases might be useful too: https://wiki.debian.org/Cloud/AmazonEC2Image