Issue
I would like to build a program using clang on x86_64 and gerate the program to x86. So far so good, I just used this command:
$ clang++ -m32 main.cpp
However, I got some errors about headers and libraries.
This same situation with gcc, would be fixed by gcc-mutilib, but clang has not some multilib package.
If I install gcc-multilib, so I can do with clang -m32, although, I just want to install clang, excluding gcc package.
Solution
xy deng's answer is on the right track. If you are compiling an x86 program on an x86 host, you just need to run
sudo apt-get install libc6-dev
But if you are on an x86_64 host and want to cross-compile a program to x86, don't try installing libc6-dev:i386
. You need the Apt package marked specifically for cross-compiling:
sudo apt-get install libc6-dev-i386-cross
This AskUbuntu answer has more information about how Ubuntu and Apt organize these headers for cross-compiling.
Answered By - James Mishra