assembly ld:未找到-l的库链接Apple Silicon时出现系统错误

whhtz7ly  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(97)

xcode是版本14.3.1(14 E300 c)Mac OS是Ventura 13.5
我正在运行的命令:ld hello.o -o hello -l System -syslibroot 'xcrun -sdk macosx --show-sdk-path' -e _main -arch arm64
链接器生成错误ld:找不到-lSystem的库
我正在玩一个为苹果硅汇编程序编写的简单的hello world程序。源文件是hello. s。对象文件是hello。o我得到“ld:找不到-l的库系统错误。上面的xcrun命令的结果是:/应用/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
系统库文件为:libSystem.dylib我在这里找到了这个文件:/应用/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libSystem.dylib
尝试系统库的该路径似乎无法解决问题。我看到这似乎是附加到iPhone os模拟器?我应该在MacOS目录中找到此库的另一个副本吗?

l0oc07j2

l0oc07j21#

我找到了一个解决方案,所以我将在这里分享给下一个搜索的人。在我找到的示例代码中,对main例程的引用是_main。将其更改为其他内容,例如_start,然后使用-e _start可以解决问题。在较新的MacOS版本中,ld似乎与_main有问题。

相关问题