gpt4 book ai didi

c - Apple Mach-O 链接 (Id) 错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:03:03 25 4
gpt4 key购买 nike

我的代码与 this 相同我之前问过的问题,所以在这里复制它没有意义

这是我遇到的错误:

Undefined symbols for architecture x86_64:
"_stdscr", referenced from:
_screen_init in screen.o
"_werase", referenced from:
_screen_init in screen.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我过去遇到过这个错误,我觉得它与重复的函数名或其他东西有关,但我不知道如何调试它。

编辑:

将libncurses.dylib文件添加到我的项目后,上面讨论的错误消失了,但是当我调用screen_init()时又出现了新的错误;在我的 main.cpp 中:

// main.cpp

#include "screen.h"

int main(){
screen_init();
}

//新错误

Undefined symbols for architecture x86_64:
"screen_init()", referenced from:
_main 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)

几乎相同的错误,除了现在在我的主要。我还缺少另一个图书馆吗?这些错误非常神秘,而且帮助不大。

最佳答案

我想您需要将库添加到链接阶段,如果您要使用 XCode,则应将其添加到项目详细信息中:

  • 选择项目详情
  • 选择构建阶段选项卡
  • 打开带有库部分的二进制链接
  • 点击加号
  • libncurses.dylib 添加到您的项目中。

关于c - Apple Mach-O 链接 (Id) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9542170/

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