openwrt移植编译glib-2.32.4

来源:互联网 发布:淘宝店铺注册账号申请 编辑:程序博客网 时间:2024/05/21 03:26

        之前编译过glib-2.28.6,现在因为要使用bluez-5.x,需要glib-2.32.4版本以上的支持,没办法,只能再编译一下了。

        修改feeds/packages/libs/glib2/Makefile,把PKG_VERSION改成2.32.4,PKG_SOURCE压缩文件后缀改成.tar.xz。

        openwrt编译glib的时候会先用GCC编译I386版,编译安装成功之后才会编译target使用的版本,首先要在电脑上安装glib的一些依赖库,我的ubuntu还差libffi和libelf

,所以先安装这两个库

# sudo apt-get install libffi-dev libelf-dev

编译之前先指定libffi和libelf的链接路径

# export LIBFFI_CFLAGS="-I/usr/include/i386-linux-gnu"
# export LIBFFI_LIBS="-L/usr/lib/i386-linux-gnu -lffi"
# export LIBELF_LIBS="-L/usr/lib -lelf"

不然会找不到这个两个库:

checking for LIBFFI... no
configure: error: Package requirements (libffi >= 3.0.0) were not met:
No package 'libffi' found

.

.

gresource-gresource-tool.o: In function `get_elf':
gresource-tool.c:(.text+0x39d): undefined reference to `elf_version'
gresource-tool.c:(.text+0x3cf): undefined reference to `elf_begin'
gresource-tool.c:(.text+0x3dd): undefined reference to `elf_kind'

GCC编译过程很顺利,就是电脑比较慢,花了比较长的时间,然后就是用交叉编译工具编译了,同样,依赖的库libffi和libelf要先编译安装。

编译的第一步,configure的时候就遇到问题了

checking for guint32... yes
checking alignment of guint32... configure: error: in `/home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4':
configure: error: cannot compute alignment of guint32
See `config.log' for more details
make[2]: *** [/home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/.configured_] Error 77
make[2]: Leaving directory `/home/luotong/working/openwrt/openwrt/feeds/packages/libs/glib2'
make[1]: *** [package/feeds/packages/glib2/compile] Error 2
make[1]: Leaving directory `/home/luotong/working/openwrt/openwrt'
make: *** [package/glib2/compile] 错误 2

检查guint32数据类型对齐失败,以前从没碰到过,打开config.log查看具体是错在哪里

configure:28483: result: yes
configure:28491: checking alignment of guint32
configure:28496: mips-openwrt-linux-uclibc-gcc -c -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib/libiconv-stub/include -I/home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib/libintl-stub/include  -Wall -I/home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include -I/home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/include -I/home/luotong/working/openwrt/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include -I/home/luotong/working/openwrt/openwrt/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/include -I/home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib/libiconv-stub/include -I/home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib/libintl-stub/include  -pthread conftest.c >&5
conftest.c: In function 'main':
conftest.c:201:12: error: storage size of 'test_array' isn't constant
conftest.c:201:12: warning: unused variable 'test_array' [-Wunused-variable]

调用AC_CHECK_ALIGNOF的时候生成了一个conftest.c文件,编译它的时候报出了错误: error: storage size of 'test_array' isn't constant,google了一下,原因是没有包含stddef.h头文件导致offsetof函数没有定义,解决办法是在configure.ac调用AC_CHECK_ALIGNOF之前check一下stddef.h头文件,

AS_IF([false], [AC_CHECK_HEADER([stddef.h])])

这个方法我没有使用,我直接定义

AC_DEFINE(STDC_HEADERS,1,[Define to include stddef.h])

好了,configure通了,往下编译,最后出现一个错误:

touch /home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/.built
mkdir -p /home/luotong/working/openwrt/openwrt/bin/ar71xx/packages /home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/ipkg-ar71xx/glib2/CONTROL /home/luotong/working/openwrt/openwrt/staging_dir/target-mips_r2_uClibc-0.9.33.2/pkginfo
install -d -m0755 /home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/ipkg-ar71xx/glib2/usr/lib
cp -fpR /home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/ipkg-install/usr/lib/*.so* /home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/ipkg-ar71xx/glib2/usr/lib/
find /home/luotong/working/openwrt/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/glib-2.32.4/ipkg-ar71xx/glib2 -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
Package glib2 is missing dependencies for the following libraries:
libffi.so.5
make[2]: *** [/home/luotong/working/openwrt/openwrt/bin/ar71xx/packages/glib2_2.32.4-3_ar71xx.ipk] Error 1
make[2]: Leaving directory `/home/luotong/working/openwrt/openwrt/feeds/packages/libs/glib2'
make[1]: *** [package/feeds/packages/glib2/compile] Error 2
make[1]: Leaving directory `/home/luotong/working/openwrt/openwrt'
make: *** [package/glib2/compile] 错误 2

这个时候其实已经编译成功了,只是生成ipk出错:缺少libffi库,这个需要修改packages/libs/glib2/Makefile

define Package/glib2
  SECTION:=libs
  CATEGORY:=Libraries
  DEPENDS:=$(ICONV_DEPENDS) $(INTL_DEPENDS) +zlib +libpthread +libffi +libelf
  TITLE:=glib 2.0
  URL:=http://www.gtk.org/
endef

打包的时候增加libffi和libelf的依赖;OK,编译成功,把glib2_2.32.4-3_ar71xx.ipk和依赖的库libffi_3.0.10-1_ar71xx.ipk和libffi_3.0.10-1_ar71xx.ipk拷贝到板子上进行安装

# opkg install libffi_3.0.10-1_ar71xx.ipk

# opkg install libffi_3.0.10-1_ar71xx.ipk

# opkg install glib2_2.32.4-3_ar71xx.ipk






0 0
原创粉丝点击