ubuntu16.04 环境配置 ncurses 出错信息:

本文解决了ncurses在编译过程中遇到的两个典型问题:一是构建terminfo数据库时出现的符号查找错误;二是从源码编译ncurses 6.0时lib_gen.c的报错。文中详细记录了问题排查过程及解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


make[1]: Entering directory `/lamp/ncurses-5.6/misc'
 DESTDIR= \
        prefix=/usr \
        exec_prefix=/usr \
        bindir=/usr/bin \
        top_srcdir=.. \
        srcdir=. \
        datadir=/usr/share \
        ticdir=/usr/share/terminfo \
        source=terminfo.tmp \
        THIS_CC="gcc" \
        THAT_CC="gcc" \
        /bin/sh ./run_tic.sh
 ** Building terminfo database, please wait...
 Running tic to install /usr/share/terminfo ...
 
        You may see messages regarding extended capabilities, e.g., AX.
        These are extended terminal capabilities which are compiled
        using
                tic -x
        If you have ncurses 4.2 applications, you should read the INSTALL
        document, and install the terminfo without the -x option.
 
tic: symbol lookup error: tic: undefined symbol: _nc_check_termtype2
 ? tic could not build /usr/share/terminfo
 make[1]: *** [install.data] Error 1
 make[1]: Leaving directory `/lamp/ncurses-5.6/misc'
 make: *** [install] Error 2
 
解决方法  
 
之前用的是ncurses-5.6。下载个新版本,如ncurses 5.9就可以解决。安装方法可以完全按照文档的选项。

ncurses5.9下载地址:

编译ncurses5.9时 再次报错

解决从源码编译ncurses6.0编译lib_gen.c报错的问题

直接从官网的源码编译时,会提示报错:

gcc -DHAVE_CONFIG_H -I. -I../include  -D_GNU_SOURCE -DNDEBUG -O2 --param max-inline-insns-single=1200 -c ../ncurses/lib_gen.c -o ../objects/lib_gen.o
In file included from ./curses.priv.h:325:0,
                from ../ncurses/lib_gen.c:19:
_18018.c:843:15: error: expected ‘)’ before ‘int’
../include/curses.h:1631:56: note: in definition of macro ‘mouse_trafo’
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
                                                        ^
Makefile:967: recipe for target '../objects/lib_gen.o' failed
make[1]: *** [../objects/lib_gen.o] Error 1
make[1]: Leaving directory '/home/abuu/project/ncurses-6.0/ncurses'
Makefile:113: recipe for target 'all' failed
make: *** [all] Error 2

报错信息提示宏参数不正确,于是在lib_gen.c中搜索wmouse_trafo或者mouse_trafo。

在lib_gen.c中检索时,发现这部分的代码与上边格式不一致,于是尝试手动修改这部分代码,尝试与文件中的其他部分代码一致。

手动修改后,依然继续报错。于是想了解如何自动生成该文件。

在生成日志中,找到如下命令:

/bin/sh -e ./base/MKlib_gen.sh "gcc -E -DHAVE_CONFIG_H -I. -I../include  -D_GNU_SOURCE -DNDEBUG" "mawk" generated <../include/curses.h >lib_gen.c

了解到lib_gen.c是通过脚本ncurses/base/MKlib_gen.sh读取文件include/curses.h后生成的。

打开include/curses.h文件时,发现该文件是通过多个文件生成合并的。查找到跟wmouse_trafo相关的代码是由curses.tail文件引入生成。

查找到mouse_trafo所在行的代码:

extern NCURSES_EXPORT(bool)    mouse_trafo (int*, int*, bool);              /* generated */

于是怀疑是否因为后边注释的问题导致的。

删除include/curses.h中mouse_trafo所在行的注释,重新make,顺利编译通过.



总结:

这个错误是因为curses.tail文件中的多出来的“/* generated */”注释,删掉它,再删掉curses.h,重新make即可。








转载于:https://www.cnblogs.com/zenghongjun/p/7146235.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值