How to compile 32-bit executable on 64 bit system
You have to install correct development packages by
sudo apt-get install build-essential libc6-dev-i386
And then it will work:
$ gcc hello.c -o hello32 -m32 $ file hello32 hello32: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=444fafde1d2281a8af74adc452a8db046df1276e, not stripped
Yup - it turns out all you have to do is install libc6-dev-i386 - then everything works.
Thanks for the tip!
Note: There is a lot of confusing and wrong information on the Internet...