views:

616

answers:

1

What is the best way to compile programs with DMD on a 64bit machine? It doesn't need to compile to 64Bit code. I know about GDC, but want to work with D2 also. There is also chroot, but am hoping for a simpler way.

The actual problem isn't with compiling, but linking. DMD calls on GCC to perform linking with system libraries. Could I get DMD to have GCC link against 32bit library? Or how would I do it manually?

I already have the ia32 libraries installed which is why I can run DMD.

+4  A: 

Ask GCC to perform 32-bit link by passing it '-m32' flag.

It appears that DMD doesn't invoke gcc to perform the link, but rather invokes ld directly. The equivalent ld switch is '-melf_i386', and apparently the way to make DMD pass that option to the linker is with '-L-melf_i386' flag.

Note that many systems separate runtime and development libraries. 32-bit runtime packages are almost always installed by default, but 32-bit development packages may not be.

You need development 32-bit packages to build 32-bit programs. The fact that 32-bit DMD can run does not in itself prove that you have all the 32-bit libraries you need in order to build 32-bit programs.

Employed Russian
Thank you. And to complete the answer, The needed package for development is gcc-multilib. Also the switch I used was -melf_i386 and to have dmd forward to gcc -L-melf_i386. Could you update your answer?
he_the_great