1.序
之所以不选最新的glib库,而选glib-2.26.1库,是有原因的,第一最新库依赖的库文件太多,编译出来库文件太大,不太适合flash空间有限的嵌入式设备. 但是在configure ’ glib-2.26.1 ’ 库的时候,碰到了许多问题。此博客记录这些问题及解决方法。
./configure 出问题,还得找根本原因,看脚本.而configure文件则是autoconfig 自动生成的. 所以建议大家去看一下 automake 及 autoconfig的官方资料.
编译命令:
./configure --enable-silent-rules --enable-shared --with-pcre=internal --disable-gtk-doc-html \
--host=arm-hisiv400-linux --prefix=$HOME/linuxfromscratch/target/glibc/arm/hi3518ev200 \
--cache-file=arm-hisiv400-linux.cache CC="arm-hisiv400-linux-gcc" \
CFLAGS="-fPIC -Wall -Wno-format -fno-strict-aliasing -O2 -I$HOME/linuxfromscratch/target/glibc/arm/hi3518ev200/include " \
LDFLAGS="-L$HOME/linuxfromscratch/target/glibc/arm/hi3518ev200/lib " \
2.问题集锦
X86平台直接忽略,只讲ARM平台交叉编译。
2.1 问题1
checking size of __int64... 0
checking for format to printf and scanf a guint64... none
checking for an ANSI C-conforming const... yes
checking if malloc() and friends prototypes are gmem.h compatible... no
checking for growing stack pointer... configure: error: in `/home/leon/Templates/glib/glib-2.26.1':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
碰到这种问题,一个最有效的方式是,直接搜索configure文件,搜索关键字 growing stack pointer ,可以找到 这样一句脚本
if test "${glib_cv_stack_grows+set}" = set; then :
解决:
echo glib_cv_stack_grows=no>arm-hisiv400-linux.cache
2.2 问题2
checking for dlopen in -ldl... yes
checking for dlsym in -ldl... yes
/opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../target/usr/lib/crt1.o: In function `_start':
:(.text+0x34): undefined reference to `main'
collect2: error: ld returned 1 exit status
checking for RTLD_GLOBAL brokenness... no
checking for preceeding underscore in symbols... configure: error: in `/home/leon/Templates/glib/glib-2.26.1':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
configure文件:
if test "${glib_cv_uscore+set}" = set; then :
解决:
echo glib_cv_uscore=no>>arm-hisiv400-linux.cache
2.3 问题3
checking for gmtime_r... (cached) yes
checking for posix getpwuid_r... configure: error: in `/home/leon/Templates/glib/glib-2.26.1':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
configure文件:
if test "${ac_cv_func_posix_getpwuid_r+set}" = set; then :
解决:
echo ac_cv_func_posix_getgrgid_r=no>>arm-hisiv400-linux.cache
2.4 问题4
checking for posix getpwuid_r... configure: error: in `/home/leon/Templates/glib/glib-2.26.1':
configure: error: cannot run test program while cross compiling
configure文件:
if test "${ac_cv_func_posix_getpwuid_r+set}" = set; then :
解决:
echo ac_cv_func_posix_getpwuid_r=no>>arm-hisiv400-linux.cache