【发布时间】:2017-01-21 22:54:14
【问题描述】:
我使用的是 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 会修复它,但我不想将其编译为 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 位输出?
【问题讨论】:
-
array.length返回size_t,在 32 位系统上是uint,在 64 位系统上是ulong。ulong在 i86(“32 位”)系统上绝对可用。
标签: linux d 32bit-64bit ld