我是 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;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用命令编译它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)
Run Code Online (Sandbox Code Playgroud)
当我将 -v 选项添加到链接器命令行时,我收到大量这种形式的消息:
ld: warning: ignoring file '/Library/D/dmd/lib/libphobos2.a[12543](biguintcore_218b_517.o)': found architecture 'x86_64', required architecture 'arm64'.
Run Code Online (Sandbox Code Playgroud)
这使得问题似乎与我使用的是 M1 有关。但是,当我显式地将-arch x86_64选项添加到链接器命令行时,我得到以下信息:
peter@hurricane source % cc -arch x86_64 -v app.o -o app -m64 -Xlinker -no_compact_unwind -L/Library/D/dmd/lib -lphobos2 -lpthread -lm
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch x86_64 -platform_version macos 14.0.0 14.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o app -L/Library/D/dmd/lib -L/usr/local/lib app.o -no_compact_unwind -lphobos2 -lpthread -lm -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a
ld: multiple errors: symbol count from symbol table and dynamic symbol table differ in '/Users/peter/BOK/D/hello/source/app.o' in '/Users/peter/BOK/D/hello/source/app.o'; address=0x0 points to section(2) with no content in '/Library/D/dmd/lib/libphobos2.a[3228](config_a94_4c3.o)'
Run Code Online (Sandbox Code Playgroud)
所以我又陷入困境了。我可以使用命令确认file该app.o文件适用于 x86_64 架构。
谢谢,彼得
小智 5
这是使用最新 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/ntmfxywgjekftcfcwhnl@forum.dlang.org
| 归档时间: |
|
| 查看次数: |
157 次 |
| 最近记录: |