在 Xcode 中,如何在项目设置中指定正确的库以避免链接错误?
我在尝试构建 XCode 项目时遇到未定义符号错误,我很确定这是因为链接器找不到库(顺便说一句,这是使用 curses.h 所需的库)。我正在写一个终端程序。我得到的错误是:
Undefined symbols:
"_initscr", referenced from:
_main in RogueSmackCmdLine.o
"_wrefresh", referenced from:
_main in RogueSmackCmdLine.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
令人讨厌的代码行是:
WINDOW *win = initscr ();
wrefresh(win);
这对你们中的一些人来说应该很容易。帮助您在项目设置中找到正确的位置并了解要放在那里的内容,我们将不胜感激。
I get a Undefined symbols error attempting to build an XCode project, and I'm pretty sure it is because the linker can't find a library (it's the library needed to use curses.h btw). I'm writing a terminal program. The errors I'm getting are:
Undefined symbols:
"_initscr", referenced from:
_main in RogueSmackCmdLine.o
"_wrefresh", referenced from:
_main in RogueSmackCmdLine.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
and the offending lines of code are:
WINDOW *win = initscr ();
wrefresh(win);
This oughta be easy for some of you guys. Help finding the right place in the Project Settings and knowing what to put there wd be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这些来自 ncurses。您应该在 Xcode 文件浏览器中右键单击 Frameworks 文件夹,选择“添加”->“现有框架...”,然后从列表中选择 libncurses(或 libcurses)。
Looks like those are from ncurses. You should right-click on your Frameworks folder in Xcode's file browser, select Add->Existing Frameworks…, and select libncurses (or libcurses) from the list.