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


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即可。








posted @ 2017-07-10 15:58  曾宏俊  阅读(1092)  评论(0编辑  收藏  举报