Why is the 32-bit .deb package not installed on 64-bit Ubuntu?

My .deb package, built on 32-bit Ubuntu and containing executables compiled with gcc, will not be installed on the 64-bit version of the OS (the error message says "Invalid i386 architecture"). This bothers me because I thought that in general 32-bit software runs on 64-bit hardware, but not vice versa.

Will it be possible to create 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 create executable files (and if so, what are they) or the .deb file itself somehow specific to one processor architecture?

+4
source share
2 answers

The deb installer probably refuses to install your package because it is (correctly) marked with the conflicting Architecture: field. I386 code can be executed on an amd64 machine, but this requires all the relevant dependencies (32-bit libraries, etc.). It is better to create separate packages for each architecture.

Yes, you can build a 32-bit machine for a 64-bit version. It is called cross-compilation, and this requires creating an assembly environment. To get started, you may need to find the dpkg-cross and apt-cross tools.

Alternatively, you can simply install a virtual machine with a 64-bit OS and build your secondary architecture there.

+6
source

Architecture is just an option in the debian package configuration file. By default, it uses uname commands. You can override it, but there is an easier way.

In general, most 32-bit programs work fine on 64-bit ones. However, if you do not have a very old PC, it is also very easy to install the mini 64-bit debian in the virtual machine virtual machine. You probably only need the base + built-in libraries + dev. It does not take up much disk space. If you can free up 2G disk space, just install the debian desktop.

There are more options for cross-compiling with varying degrees of automation.

I use the virtualbox method regularly. It is quick and easy.

If you are running 64-bit Linux, creating a 32-bit environment is as simple as mkdebootstrap + linux32 + chroot.

+2
source

Source: https://habr.com/ru/post/1312624/


All Articles