[cfe-dev] Generating 32-bit Code on 64-bit Linux System

John Criswell criswell at illinois.edu
Tue Sep 13 13:35:15 PDT 2011


Dear All,

I'm trying to compile a "Hello, world!" C++ program on a 64-bit Linux 
machine into a 32-bit ELF program using Clang as follows:

clang++ -o test -m32 test.cpp

Unfortunately, I get the following error:

/usr/bin/ld: skipping incompatible 
/usr/lib/gcc/x86_64-redhat-linux6E/4.4.4/libstdc++_nonshared.a when 
searching for -lstdc++_nonshared
/usr/bin/ld: cannot find -lstdc++_nonshared

Am I using the correct flags to get clang++ to generate 32-bit code?  If 
so, does anyone know what the problem might be?  Omitting the -m32 
generates a 64-bit executable correctly.

On a related note, is there an LLVM configure option that will generate 
a clang executable that always generates 32-bit code?

-- John T.




More information about the cfe-dev mailing list