1.内核编译和编译体验
错误:
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
*** Install ncurses (ncurses-devel) and try again.
解析:提示没有安装ncurses
(参考:http://blog.csdn.net/wang__rongwei/article/details/54846759)
使用apt install ncurses-devel命令安装该库,没有,然后又使
用apt install ncurses,还是没有该库。
说明有可能库名字在新的ubuntu版本中发生改变,因此
到底名字变成什么了???
可以判定Ubuntu软件管理器服务端有作修改过。
所以到 Ubuntu Package archive(http://packages.ubuntu.com/)
搜索是否存在该安装包,用
'ncurses-devel'作为关键字搜索,没有任何结果。搜索'ncurses'出现了
很多返回结果。根据每个返回搜索结果的说明可以发现
在Ubuntu中'ncurses-devel'是以'libncurses5-dev'命名的。
安装apt install libncurses5-dev
也会出现错误 提示 没有安装。。。直接运行提示即可。
错误:
Your display is too small to run Menuconfig!
It must be at least 19 lines by 80 columns.
解决方案:全屏,或者是把字体调小。
错误:
Can’t use ‘defined(@array)’ (Maybe you should just omit the defined()?)at kernel/timeconst.pl line 373.
解析:
使用ubuntu14.04(64bit)编译linux2.6.39.4并没有出现什么错误,但是使用ubuntu16.04.1(64bit)编译linux-2.6.39.4时,却提示Can’t use ‘defined(@array)’ (Maybe you should just omit the defined()?)错误。
(参考:http://blog.csdn.net/abc87891842/article/details/55051042)
参考:编译kernel perl版本bug
最近升级了一下MAC系统,突然发现android的Linux kernel无法编译通过了,
其实,提示的错误信息已经明确告诉你了,你应该省略defined().
这里,我们打开 kernel/timeconst.pl
@val = @{$canned_values{$hz}};
if (!defined(@val)) {
@val = compute_values($hz);
}
output($hz, @val);
将if (!defined(@val)) 改为if (!(@val)),再次编译就
可以通过了。
查了一下更新,发现其中有一项是perl版本升级到了 v5.22.1,
然后查了perl官方文档,发现官网因为一个bug,
该版本将defined(@array)去掉了。可以直接使用数组判断非空。
2.buildroot 编译
错误:
error: expected ‘)’ before ‘int’
解析:
解决从源码编译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即可。