在Ubuntu上使用makefile的问题

时间:2015-12-30 22:32:44

标签: c ubuntu makefile

我正在尝试安装一个包含一些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上)

1 个答案:

答案 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