Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取Apple Mach-O链接器错误C99。我怎么修理它?_C_Xcode_C99_Mach O - Fatal编程技术网

获取Apple Mach-O链接器错误C99。我怎么修理它?

获取Apple Mach-O链接器错误C99。我怎么修理它?,c,xcode,c99,mach-o,C,Xcode,C99,Mach O,/Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/bin/clang-arch x86_64-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk-L/Users/ashutshagarwal/Library/Develop

/Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/bin/clang-arch x86_64-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk-L/Users/ashutshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqsfegd/Build/Products/DebugF/UsutoSuqHuqQudQuqQuqQuSFQFDGD/Buff/Studio/Studio /产品/调试/库/开发者/ XDCOD/派生数据/C-CNYFLVMJYAUQUQUQQFEGD/Buff/Cudio/CuBud/CdBug/Objuts/Orthy/X86Y64/C.Link KFielSist-MMACOSX版本MIN=10.9 -框架基金会- Xlinker-依赖关系\信息-Xlinker/Users/ashutshaagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqsqfegd/Build/Intermediates/c.Build/Debug/c.Build/Objects-normal/x86\ u 64/c\依赖关系\信息.dat-o/Users/ashutshaagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqfegd/Build/Products/Debug/c-c

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

错误消息:

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)

告诉您链接器找不到符号
readline
add\u history
。如果没有看到您的源代码,以及精确的链接器和编译器命令行,很难推测确切的原因。一个可能的原因是您未能链接到外部库或程序的其他模块。

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

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)'
(T
表示符号位于库的文本部分)


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

变量。您已经发布了该文件(使用桌面上的图像),并且该文件已被删除。您尚未更改此报表中的任何内容。如果有人在尝试更正阅读文本“Build Your Own Lisp”时发现此问题,这就是解决方案。此外,您需要从代码中删除这一行:#include
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)'
$ 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