Reputation: 255
I'm 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'll need a 64 bit OS, which can build both 32 and 64. Adding the -m32 flag will produce the right output for 32, no challenge here.
The main issue is with libraries. I'm not sure on how to proceed... How can I make sure the linker is using the 32 bit versions of simple libraries, such as ldl, lz, lrt? I understand I must 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 and so on. Should I use the oldest versions, in order to ensure all clients will run without issues? I mean, if I build the app in the latest Debian, in older Debians it won't work properly, correct?
Thanks for the help!
Upvotes: 6
Views: 1051
Reputation: 129454
Most versions of Linux that have a 64-bit build also make a 32-bit build and nearly all libraries are available for both, so all you need to do is install the relevant 32-bit libraries in parallel with the 64-bit ones. The configuration of paths is no different than for a pure 64- or 32-bit build in most cases. There may be a few libraries that have problems, but you really need to go looking for those. All of the mainstream packets will have libraries that work with 32- and 64-bit library versions both installed at the same time.
When it comes to "which libc", etc, that's a more difficult question, since it will really depend on what your customers have on their machines - and it's unlikely that you can dictate that they should be using one of Debian, RedHat or SuSE - they will feel very strongly about using whatever they are using. Using a "too old" library is just as bad as using a "too new" library. The usual solution to this is to build multiple versions, one for a selected RedHat release (and that should work with a few steps newer/older version, typically, as well as the Fedora versions in the same range), a Debian version, and a SuSE version, maybe one or two more distros.
And yes, at that point, you probably want to set up a build machine with a few virtual machines on it, so that you don't have to have 3, 5, or 12 physical machines.
Upvotes: 2