Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a 64bit Debian package on a 32bit machine

I'm trying to create an amd64 package using:

sudo dpkg-buildpackage -us -uc -aamd64

on an i386 machine.

The error I get is:

Can't exec "x86_64-linux-gnu-strip": no such file or directory at /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm line 215

Any suggestions?

like image 319
Andy Thomas Avatar asked Nov 02 '22 00:11

Andy Thomas


1 Answers

Building a cross compiler/binutils is often very hard, and it doesn't allow you to test your programs.
Virtual machines are very slow and create a strong separation which make hard to share files between the host an the VM.

The fastest solution and KISS way is Qemu-User-static : system-calls are translated in 32-bits in user mode. A 64-bits kernel does the same for 32-bits apps (but in kernel mode).

Download or extract a rootfs from a 64-bits Debian livecd.
Copy it to a sub-folder of you real root directory.
Copy qemu-user-x86_64 to a folder of $PATH relative to the fresh extracted rootfs.
copy /etc/resolv.conf to /your_path_to_target/etc/resolv.conf Chroot to it by executing /bin/bash.
Launch apt-get for installing the necessary tools.
Use the rootfs as if you were using a real 64-bits machine.

Things became very simple : Many libraries don't compile because of things like hard-coded paths (you'll face many; many problems like the one you have with cross-compiling). Here all happen as if you build packages natively and the executables were IA-32.

If you are using an x86_64 CPU along a 64-bit kernel, you can skip the whole qemu part. Just extract a 64-bits rootfs and chroot to it : it will be the fastest possible solution which can exist and dpkg-buildpackage will always work (no need to use tools like pbuilder).
Don't forget to copy /etc/resolv.conf if you want to use networking inside chroot.

.

If you use a 32-bits kernel on a 64-bits system, you can use qemu-kvm with a modified bios it will be faster than qemu-user because no JIT recompilation is required.

like image 199
user2284570 Avatar answered Nov 15 '22 07:11

user2284570