Ubuntu 14.04
sudo apt-get install gcc-multilib
For some reason, on Ubuntu 17.04, I also needed to install a version-related version:
sudo apt-get install gcc-6-multilib
Then minimal world hi:
#include <stdio.h> int main() { puts("Hello world!"); return 0; }
compiles without warning:
gcc -m32 -pedantic-errors -std=c89 -Wall hello_world.c
and
./a.out
gives: Hello world! as expected, and:
file a.out
He speaks:
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=87c87a83878ce7e7d23b6236e4286bf1daf59033, not stripped
and
qemu-i386 a.out
also gives: Hello world! but crash for x86_64 executable
In addition, I have:
So I think this works :-)
See also: Cannot find crtn.o by associating 32-bit code with a 64-bit system
Ciro Santilli 华 涌 低端 人口 六四 事件 法轮功 Apr 24 '15 at 13:34 2015-04-24 13:34
source share