gpt4 book ai didi

c - 出现 Apple Mach-O 链接器错误 C99。我如何解决它?

转载 作者:行者123 更新时间:2023-11-30 18:56:47 24 4
gpt4 key购买 nike

Ld /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug/c normal x86_64
cd /Users/ashutoshagarwal/Desktop/c
setenv MACOSX_DEPLOYMENT_TARGET 10.9

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug -F/Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug -filelist /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Intermediates/c.build/Debug/c.build/Objects-normal/x86_64/c.LinkFileList -mmacosx-version-min=10.9 -framework Foundation -Xlinker -dependency_info -Xlinker /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Intermediates/c.build/Debug/c.build/Objects-normal/x86_64/c_dependency_info.dat -o /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug/c

Undefined symbols for architecture x86_64:
"_add_history", referenced from:
_main in main.o
"_readline", referenced from:
_main in main.o
_source in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我收到 Apple-Mach-O 链接器 (Id) 错误,已花费数小时尝试修复此错误,不知道该怎么办。

最佳答案

看起来您正在使用 GNU readline 和 GNU 历史库,默认情况下,它们在 Mac 上的 libedit.dylib 中可用:

$ nm /usr/lib/libedit.dylib | fgrep readline
0000000000009899 T _readline
000000000001f444 D _readline_echoing_p
000000000001f400 D _rl_readline_name
000000000001f3f8 D _rl_readline_version
$ nm /usr/lib/libedit.dylib | fgrep add_history
000000000000acbc T _add_history

(T 表示该符号位于库的文本部分)。

因此您需要将 -ledit 添加到链接器命令行中。如果您使用的是 Xcode,那么您可以将 libedit.dylib 添加到要链接的库列表中,或者如果您使用的是 make,那么您可能必须编辑 Makefile 中的 LIBS 变量。

关于c - 出现 Apple Mach-O 链接器错误 C99。我如何解决它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23313732/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com