c - Ubuntu 上的 makefile 问题

标签 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 上)

最佳答案

您已使用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/

相关文章:

c - UDP 套接字无法接收 ECONNREFUSED

linux - 使用ubuntu找出内存被吃掉的地方

linux - 命令行连接到无线网络在 ubuntu 10.04 上不起作用

c++ - 升级到 OS X Mavericks 后架构 x86_64 的 OpenCV undefined symbol

c - OpenSSL 中的 ENGINE 是什么?它的用途是什么?

c - 在 C 中获取 X 分钟前的时间

c - 嵌套for循环,运行系列10000次

ruby-on-rails - Rvm - Linux Ubuntu 上的 Capistrano 集成

bash - 双 "at"(@@) 符号在 Makefile 中有什么作用?

makefile - 制作 : execute 2nd rule only if 1st changed file