【问题标题】:Compiling for 32 bit on a 64 bit DMD在 64 位 DMD 上编译 32 位
【发布时间】: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 位系统上是 ulongulong 在 i86(“32 位”)系统上绝对可用。

标签: linux d 32bit-64bit ld


【解决方案1】:

自己解决了这个问题。原来,我错过了链接器所需的一些包。这解决了问题:

sudo apt install gcc-multilib

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 2013-10-20
    相关资源
    最近更新 更多