在项目中使用外部SDK集成的uClibc库中的system函数时遇到了问题,想要调试一下,所以从uClibc官网下载了uClibc的最新版本0.9.33.2。交叉编译基于该版本进行,工具链是arm-hisiv100nptl-linux-。
第一步,选择系统平台
第二步,指定目标架构的特性和选项,进去选择和设定
这里最重要的是设置KERNEL_HEADERS的值:它不是linux内核中的include路径,而是交叉工具链中的include路径。
第三步,设置工具链和调试选项
进去设置交叉工具链:
这是交叉编译最关键的三步,设置好后就可以编译得到uClibc的库了。至于特性裁剪,需要因地制宜,这里就不讨论了。
问题说明
第二步中KERNEL_HEADERS选项的设置很重要,如果设置成linux源码树中的include路径,将编译出错,找不到头文件:
lzh@ubuntu:/mnt/uclibc/uClibc-0.9.33.2$ make GEN include/bits/uClibc_config.h CC libpthread/nptl/sysdeps/unix/sysv/linux/gen_lowlevelbarrier.s GEN libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.h CC libpthread/nptl/sysdeps/unix/sysv/linux/gen_lowlevelcond.s GEN libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelcond.h CC libpthread/nptl/sysdeps/unix/sysv/linux/gen_lowlevelrobustlock.sIn file included from ./include/errno.h:36, from ./include/bits/syscalls.h:31, from ./include/sys/syscall.h:34, from ./libpthread/nptl/pthreadP.h:26, from libpthread/nptl/sysdeps/unix/sysv/linux/gen_lowlevelrobustlock.c:2:./include/bits/errno.h:25: fatal error: linux/errno.h: No such file or directorycompilation terminated.make: *** [libpthread/nptl/sysdeps/unix/sysv/linux/gen_lowlevelrobustlock.s] Error 1lzh@ubuntu:/mnt/uclibc/uClibc-0.9.33.2$ make MKDIR include/bits GEN include/bits/uClibc_config.h LN include/semaphore.h LN include/pthread.h LN include/bits/libc-lock.h LN include/bits/stdio-lock.h LN include/bits/pthreadtypes.h LN include/bits/semaphore.h LN include/thread_db.h LN include/fpu_control.h当出现此类错误时,请check一下该选项的设置是否正确。:1: error: no include path in which to search for asm/unistd.h :1: error: no include path in which to search for asm/unistd.hERROR: Could not generate syscalls.Make sure that you have proper kernel headers.Your .config in KERNEL_HEADERS="" was set to:/mnt/opt/hisi-linux-nptl/arm-hisiv100-linux/target/usr/include/make: *** [include/bits/sysnum.h] Error 1