Multiarch working
2 minutes read

After about a week of gcc compiles, I have multiarch working now. Mostly, at least:

(hoary-clean)root@shonap:/tmp# cat hello.c
#include <stdio.h>

int main(int argc, char **argv) {
  fprintf(stderr, "hello multiarched world\n");

A trivial hello.c. Then, we have a multiarched libc6 and libc6-dev:

(hoary-clean)root@shonap:/tmp# ls /usr/include/stdio.h
ls: /usr/include/stdio.h: No such file or directory
(hoary-clean)root@shonap:/tmp# ls /usr/include/i386-linux/stdio.h

Matching libraries:

(hoary-clean)root@shonap:/tmp# ls /usr/lib/ /lib/
ls: /usr/lib/ No such file or directory
ls: /lib/ No such file or directory
(hoary-clean)root@shonap:/tmp# ls -1 /usr/lib/i386-linux/ /lib/i386-linux/

Then, compile, check, run:

(hoary-clean)root@shonap:/tmp# gcc-3.4 hello.c -o hello
(hoary-clean)root@shonap:/tmp# file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped
(hoary-clean)root@shonap:/tmp# ldd hello
       => /lib/i386-linux/ (0xb7eb1000)
        /lib/ => /lib/ (0xb7fea000)
(hoary-clean)root@shonap:/tmp# ./hello
hello multiarched world


Of course, there are minor problems left, like gcc thinking that it installs the 64 bit libraries into /usr/lib/i486-linux/x86_64-linux, that it currently can’t compile for 64 bit due to the symlink from being missing and other minor stuff like that. It seems glibc also needs a minor adjustment (just a missing symlink from i486-linux to i386-linux in /usr/include).

As a final test, I scp-ed the 64 bit binary I built (after having created the libgcc_s_64 symlink by hand) to an AMD64, and it works beautifully there.

Back to posts