我在 Mac 上构建一个简单的 D 程序时遇到了令人困惑的链接错误

问题描述 投票:0回答:1

我是 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)

我对这意味着什么或如何解决这个问题感到有些困惑。欢迎任何建议!

谢谢, 彼得

macos d
1个回答
0
投票

这是使用最新 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/[电子邮件受保护]

© www.soinside.com 2019 - 2024. All rights reserved.