Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't a 32bit .deb package install on 64bit Ubuntu?

My .deb package, built on 32-bit Ubuntu and containing executables compiled with gcc, won't install on the 64-bit version of the OS (the error message says 'Wrong architecture i386'). This is confusing to me because I thought that in general 32-bit software worked on 64-bit hardware, but not vice-versa.

Will it be possible for me to produce a .deb file that I can install on a 64-bit OS, using my 32-bit machine? Is it just a matter of using the appropriate compiler flags to produce the executables (and if so what are they), or is the .deb file itself somehow specific to one processor architecture?

like image 872
codebox Avatar asked Feb 26 '23 20:02

codebox


1 Answers

The deb installer is probably refusing to install your package because it was (correctly) labeled with a conflicting Architecture: field. i386 code can be executed on an amd64 machine, but it requires that all the appropriate dependencies (32-bit libraries, etc.) be present. It's better to build separate packages for each architecture.

Yes, you can build for 64-bit on your 32-bit machine. It's called cross-compiling, and it requires that you create a build environment for that purpose. To get started, you might want to look up the dpkg-cross and apt-cross tools.

Alternatively, you can just install a virtual machine running a 64-bit OS, and build for your secondary architecture there.

like image 126
ʇsәɹoɈ Avatar answered Mar 01 '23 10:03

ʇsәɹoɈ