Linux – How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake

32-bit64-bitcmakegcclinux

Is it possible to compile a project in 32-bit with cmake and gcc on a 64-bit system? It probably is, but how do I do it?

When I tried it the "ignorant" way, without setting any parameters/flags/etc, just setting LD_LIBRARY_PATH to find the linked libraries in ~/tools/lib it seems to ignore it and only look in subdirectories named lib64.

Best Answer

export CFLAGS=-m32