在 64 位 DMD 上编译 32 位

Compiling for 32 bit on a 64 bit DMD

我用的是xubuntu 16.04 amd64,用的是D语言。我曾经在 32 位机器 (ubuntu 14.04) 上使用 DMD i386,但现在,出于某种原因,我不能(或不想)在我的系统上安装 DMD_i386,所以我为 amd64 安装了一个。我所有的项目都是在 32 位机器上编写的,我使用 int 类型而不是 64 位可用的 long 类型。现在每当我尝试编译我之前写的东西时,看起来像这样,都会出错;

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.
}

我知道将 ln 的类型更改为 ulong 会 fx 它,但我不想为 32 位编译它,而不是 64 位,在 32 位上,long/ulong 类型不可用,因为它使用 64 位。

我尝试过的: 我试过使用 -m32 开关使 DMD 产生 32 位输出。上面提到的错误已通过此修复,但出现链接器 (ld) 错误:

/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

如何让 DMD 在 64 位 DMD 上产生 32 位输出?

我自己解决了这个问题。事实证明,我缺少链接器所需的一些包。这解决了问题:

sudo apt install gcc-multilib