Linux – Compiling 32-bit binaries on 64-bit RHEL

32-bit64-bitlinuxrhel5

I have a 64-bit RHEL 5.3 server. There's a piece of server software that's more memory efficient if I compile it as 32-bit. Is there a way to tell GCC to target 32-bit?

I just want a specific piece of software to be 32-bit, everything else should stay 64-bit.

This software is not packaged in the yum repositories so I cannot just do 'yum install 32-bit-version'.

Best Answer

If you're stuck with compiling yourself, gcc accepts the -m32 option which should instruct the compiler to generate 32bit objects/executables. (Although, if you can go the route gekkz suggests, do that).