在Mac OS X上编译ncurses应用程序时出错 [英] Error while compiling ncurses app on Mac OS X
本文介绍了在Mac OS X上编译ncurses应用程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在Mac OS X 10.6.8上编译基于ncurses的应用程序,但出现此错误.
I'm trying to compile ncurses based app on Mac OS X 10.6.8 but I get this error.
Undefined symbols for architecture x86_64:
"_initscr", referenced from:
_main in ccf8K8YG.o
"_printw", referenced from:
_main in ccf8K8YG.o
"_stdscr", referenced from:
_main in ccf8K8YG.o
"_wrefresh", referenced from:
_main in ccf8K8YG.o
"_wgetch", referenced from:
_main in ccf8K8YG.o
"_endwin", referenced from:
_main in ccf8K8YG.o
可能是什么问题?
推荐答案
我很确定这是因为编译时没有包含 ncurses
库.
I'm pretty sure this is because you're not including the ncurses
library when compiling.
尝试添加:
-lncurses
编译时.
例如(对于C ++):
For example (for C++):
g++ -o hello main.cpp -lncurses
或使用gcc(用于C):
Or using gcc (for C):
gcc -o hello main.cpp -lncurses
此简短命令将编译并执行:
This short command will compile and execute:
gcc -o hello main.cpp -lncurses && ./hello
这是我的问题,希望这对某人有帮助.
This was my issue, I hope this helps someone.
这篇关于在Mac OS X上编译ncurses应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文