我正在尝试安装一个包含一些C文件的文件夹的程序。我运行makefile但是我收到以下错误:
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1128: undefined reference to `tgoto'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1129: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1138: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1145: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1154: undefined reference to `tputs'
readline/libreadline.a(display.o): In function `delete_chars':
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1182: undefined reference to `tgoto'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1183: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1189: undefined reference to `tputs'
readline/libreadline.a(signals.o): In function `cr':
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/signals.c:301: undefined reference to `tputs'
collect2: error: ld returned 1 exit status
你知道我怎么解决它? (在Ubuntu上)
答案 0 :(得分:1)
您在c程序中使用了tputs
,因此您必须使用#include <curses.h>
和#include <term.h>
。未定义的引用是链接器错误。在编译c程序的Makefile中,您应该链接-lcurses
或-lncurses
。在Makefile中添加类似的行。使用适当的链接库进行编译。
例如
gcc file.c -o output_file -lcurses -ltermcap
或
gcc file.c -o output_file -lcurses -ltermcap