Compiling 32-bit C/C++ Programs on 64-bit
By default, gcc will compile your c/c++ program to 64-bit
instructions. In order to compile to 32-bit you need to add a
-m32
flag to the command line. For example, to compile a
file called hello-world.c using a Linux terminal, you would do
something like this:
$ gcc -m32 hello-world.c -o hello-world
If you get the following error:
fatal error: bits/predefs.h: No such file or directory
it means that the multilib standard library is missing. Therefore, you must install gcc-multlib. The name is different based upon the distribution and the compiler. For Debian/Ubuntu-based distros it would be:
$ sudo apt-get install gcc-multilib # For C
$ sudo apt-get install g++-multilib # For C++
Tags: cli, programming, c, cpp, multilib, motd
Linkers
If you’re a developer who is interested in “how the sausage is made” then you might want to check out Ian Lance Taylor’s blog which contains a series of articles discussed on Klaatu’s GNU World Order Episode 400 about the linker
Here are the links to the articles:
Linkers part 1 Linkers part 2 Linkers part 3 Linkers part 4 Linkers part 5 Linkers part 6
Tags: cli, linkers, programming, compiling, motd