Linux for creating 32-bit and 64-bit applications (C ++)

I am looking for advice on how to set up a build machine for a Linux application that needs to be compiled for both 32 and 64-bit architectures.

As far as I know, I will need a 64-bit OS, which can create both 32 and 64. Adding the -m32 flag will lead to the correct exit for 32, no problem.

The main problem is libraries. I'm not sure how to proceed ... How can I make sure the linker uses 32-bit versions of simple libraries like ldl, lz, lrt? I understand that I have to install the 32-bit versions of all of them, and then configure the linker path.

Another issue is the version of the compiler, linker, libc, etc. Should I use the oldest versions to ensure that all clients work without problems? I mean, if I create an application in the latest Debian, it will not work correctly in old Debians, right?

Thanks for the help!

+6
source share
1 answer

Most versions of Linux that have a 64-bit build also create a 32-bit build, and almost all libraries are available for both, so you only need to install the corresponding 32-bit libraries in parallel with 64-bit. The configuration of the paths is no different from the configuration with 64 or 32 bits in most cases. There may be several libraries that have problems, but you really need to look for them. All major packages will have libraries that work with 32- and 64-bit versions of libraries installed at the same time.

When it comes to “volume libc”, etc., this is a more complicated question, since it will really depend on what your clients have on their machines, and it is unlikely that you can dictate that they should use one of Debian , RedHat or SuSE - they will be very versed in using what they use. Using a "too old" library is as bad as using a "too new" library. The usual solution for this is to create several versions, one for the selected version of RedHat (and this should work with several stages of a newer / older version, usually, as well as Fedora versions in the same range), the Debian version and SuSE version, possibly one or two distributions.

And yes, at that moment you probably want to set up an assembly machine with several virtual machines on it so that you don't have to have 3, 5, or 12 physical machines.

+2
source

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


All Articles