我正在尝试安装一个由包含一些 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 上)
最佳答案
您已使用tputs
在c程序中,所以你必须使用 #include <curses.h>
和#include <term.h>
。 undefined reference 是链接器错误。在编译 c 程序时的 Makefile 中,您应该链接 -lcurses
或-lncurses
。将类似的行添加到您的 Makefile 中。使用适当的链接库进行编译。
例如
gcc file.c -o output_file -lcurses -ltermcap
或
gcc file.c -o output_file -lcurses -ltermcap
关于c - Ubuntu 上的 makefile 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34538285/