我是 D 编程新手。我在 M1 处理器上使用 macOS Sonoma。我系统上的 clang 版本是 15.0.0。我安装了最新版本的 DMD (2.106)。我创建了这个程序:
import std.stdio;
int main()
{
int a = 0;
a++;
// Display the result.
writefln("a = %d", a);
return 0;
}
我尝试使用命令
dmd app.d
来编译它,其中“app.d”是包含上述代码的文件的名称。这是我收到的消息:
ld: multiple errors: symbol count from symbol table and dynamic symbol table differ in '/Users/peter/BOK/D/source/app.o' in '/Users/peter/BOK/D/source/app.o'; address=0x0 points to section(2) with no content in '/Library/D/dmd/lib/libphobos2.a[3228](config_a94_4c3.o)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我对这意味着什么或如何解决这个问题感到有些困惑。欢迎任何建议!
谢谢, 彼得
这是使用最新 xcode 时 dmd 的一个已知问题:
https://issues.dlang.org/show_bug.cgi?id=24137
LDC 已在一定程度上修复了此问题(LDC 原生支持 M1,DMD 仅支持 x86),但对于 DMD,您可能需要尝试设置环境变量 MACOSX_DEPLOYMENT_TARGET=11
相关: https://github.com/ldc-developers/ldc/issues/3864
另一个建议是使用
-ld_classic
链接器标志:
https://forum.dlang.org/post/[电子邮件受保护]