ncurses交叉编译

  • Post author:
  • Post category:其他


1.环境

编译环境:ubuntu18.04虚拟机

板端:移远AG550平台 编译链aarch64-oe-linux

2.ncurses下载

ncurses库下载地址:

Index of /pub/gnu/ncurses

下载5.9的版本

3.解压并且编译

tar xvf ncurses-5.9.tar.gz
cd ncurses-5.9

执行configure命令后出现如下错误:

./configure --prefix=/home/share/work/code/v2xapp_ql/v2xstack/opensource/ncurses-5.9/install --host=aarch64-oe-linux --with-shared
configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.
configure: loading site script /opt/ag215_crosstools/crosstools/site-config-aarch64-oe-linux
checking for egrep... grep -E
Configuring NCURSES 5.9 ABI 5 (Wed Dec  7 20:38:01 CST 2022)
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `aarch64-oe-linux': machine `aarch64-oe' not recognized
configure: error: /bin/sh ./config.sub aarch64-oe-linux failed

其中:

–prefix 是指定生成文件的路径

–host 指定的是交叉编译工具链的前缀

–with-shared 生成动态库

解决方法:

sudo apt-get install libtool
cp /usr/share/libtool/build-aux/config.sub .
cp /usr/share/libtool/build-aux/config.guess .

安装后配置完成

make编译出现错误

In file included from ../ncurses/curses.priv.h:283,
                 from ../ncurses/lib_gen.c:19:
_91379.c:835:15: error: expected ‘)’ before ‘int’
../include/curses.h:1594:56: note: in definition of macro ‘mouse_trafo’
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
                                                        ^
Makefile:794: recipe for target '../obj_s/lib_gen.o' failed
make[1]: *** [../obj_s/lib_gen.o] Error 1
make[1]: Leaving directory '/home/share/work/code/v2xapp_ql/v2xstack/opensource/ncurses-5.9/ncurses'
Makefile:109: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

根据出错提示,找到ncurses目录下,include文件夹里的curses.h文件,查找mouse_trafo,锁定在1584行:
1583 extern NCURSES_EXPORT(bool)    wmouse_trafo (const WINDOW*, int*, int*, bool);
1584 extern NCURSES_EXPORT(bool)    mouse_trafo (int*, int*, bool);   /* generated */
 
应该是由后面的一行注释引起的,具体原因不详。
由于代码的部分是由另一个文件curses.tail导入的,所以要修改curses.tail:
sudo vim curses.tail
 
查找mouse_trafo,定位到104行,去除104行后面的注释:
103 extern NCURSES_EXPORT(bool)    wmouse_trafo (const WINDOW*, int*, int*, bool);
104 extern NCURSES_EXPORT(bool)    mouse_trafo (int*, int*, bool);   /* generated */
 
保存后退出,重新make即可。

make后还是出现错误:

../c++/cursesp.h: In member function ‘T* NCursesUserPanel<T>::UserData() const’:
../c++/cursesp.h:256:43: error: no matching function for call to ‘NCursesUserPanel<T>::get_user() const’
     return reinterpret_cast<T*>(get_user ());

网上搜索后发现:

出错的原因是编译器版本过高。

解决方法有两个,一是更新ncurses到6.2版本,或者降低编译器版本。

下载6.2版本的源码重新按照上面的步骤编译一次,就可以完成编译了。



版权声明:本文为shan614667793原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。