I am using xubuntu 16.04 amd64, and use the D Language. I used to use DMD i386 on a 32 bit machine (ubuntu 14.04), but now, for some reason, I can’t (or don’t want to) install DMD_i386 on my system, so I installed the one for amd64. All of my projects were written on a 32 bit machine, and I used the int
type instead of the long
type that’s available on 64bit. Now whenever I try to compile something that I wrote earlier, that looks something like this, gives an error;
void someFunction(){ string[] someArray; uint ln = someArray.length;//This compiled perfectly on 32 bit, but now it says that someArray.length is ulong, and ln is uint. }
I know that changing ln’s type to ulong will fx it, but I wan’t to compile this for 32 bit, and not 64 bit, and on 32 bit, the long
/ulong
type isn’t available, since it uses 64 bits.
What I’ve tried:
I’ve tried using the -m32
switch to make DMD produce 32 bit output. The error mentioned above is fixed by this, but a linker (ld) error shows up:
/usr/bin/ld: cannot find crt1.o: No such file or directory /usr/bin/ld: cannot find crti.o: No such file or directory /usr/bin/ld: cannot find -lpthread /usr/bin/ld: cannot find -lm /usr/bin/ld: cannot find -lrt /usr/bin/ld: cannot find -ldl /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc /usr/bin/ld: cannot find -lgcc /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s /usr/bin/ld: cannot find -lgcc_s /usr/bin/ld: cannot find -lc /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc /usr/bin/ld: cannot find -lgcc /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s /usr/bin/ld: cannot find -lgcc_s /usr/bin/ld: cannot find crtn.o: No such file or directory collect2: error: ld returned 1 exit status --- errorlevel 1
How do I get DMD to produce 32 bit output on a 64 bit DMD?
Advertisement
Answer
Solved the problem myself. Turns out, I was missing some packages needed by the linker. This solved the problem:
sudo apt install gcc-multilib