通过 bitbake 移植 qrencode 到嵌入式

通过网上知道 qrencode 可以生成二维码,那么怎么通过它移植进设备呢

1.先下 qrencode 源码,qrencode-3.4.4.tar.gz。放入系统对应位置,打开看了一下,里面已经有configure.ac, Makefile.am等文件了,那么就不用再写了。

2.编写qrencode_git.bb文件,如下:

DESCRIPTION = "qrencode libs"			---- 描述,无所谓名字
HOMEPAGE = "http://www.qrencode.com/"	        ---- 无所谓
LICENSE = "Apache-2.0"				---- 无所谓
LIC_FILES_CHKSUM = "file://${COREBASE}/meta-oem/files/oem-licenses/${LICENSE};md5=89aea4e17d99a7cacd*******" ---- 抄其他的

PR = "r0"	---- 无所谓,r0,r1 都行

SRC_URI = "file://${WORKSPACE}/oem/app-framework/qrencode"	---- 源码目录
S = "${WORKDIR}/${PN}"						---- 编译目录

inherit autotools						---- autotools 工具

do_install_append() {										
    install -d ${D}${includedir}/				---- 抄其他的,必要 
}

3.开始编译,bitbake -fc install qrencode,duang,出错了。

那就看错误信息:

| configure.ac:85: error: possibly undefined macro: AM_PATH_SDL
|       If this token and others are legitimate, please use m4_pattern_allow.
|       See the Autoconf documentation.
| autoreconf: /build/tmp-eglibc/sysroots/x86_64-linux/usr/bin/autoconf failed with exit status: 1
| + bbfatal 'autoreconf execution failed.'
| + echo 'ERROR: autoreconf execution failed.'
| ERROR: autoreconf execution failed.
| + exit 1
可知 configure.ac 85行里,AM_PATH_SDL 这个宏没定义,那就把它屏蔽吧

if test x$build_tests = xyes ; then
	SDL_REQUIRED_VERSION=1.2.0
	#AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.]))
	AC_MSG_NOTICE([SDL check done.])
	AM_ICONV_LINK
fi

AM_PATH_SDL 这个宏是什么意思呢?这篇文章有介绍:http://www.linuxsir.org/bbs/thread239728.html   

4.再次编译,发现刚才的错误没了,但是有另外的错误了:

| configure: error: Package requirements ("libpng") were not met:
| 
| No package 'libpng' found

这是什么意思,明显是缺少 libpng 库啊,那就去增加吧。


5.找到 linpng 开源源码,我的是 libpng 1.6.17 ,里面也有 对应的configure.ac, Makefile.am等文件了,所以png_git.bb 文件跟qrencode_git.bb 差不多,不列出来了。

开编png,duang,毫无疑问没那么顺利,依旧出错了:

 configure.ac:30: require Automake 1.13, but have 1.11.2
| autoreconf: automake failed with exit status: 1
| + bbfatal 'autoreconf execution failed.'
| + echo 'ERROR: autoreconf execution failed.'
| ERROR: autoreconf execution failed.
| + exit 1

还是configure.ac 这个文件有问题,30行,根据意思有 1.11,但没有1.13,那就把configure.ac里面的1.13改成1.11吧:

AM_INIT_AUTOMAKE([1.11 foreign dist-xz color-tests silent-rules subdir-objects])

OK,编译通过了。


6.继续qrencode部分,可知qrencode依赖libpng库,那么qrencode_git.bb文件需要增加一行了:DEPENDS = "png"

再次开始qrencode编译:

bitbake -fc cleanall qrencode && bitbake -fc install qrencode

编译通过


7. qrencode 生成了 \usr\bin\qrencode ,那么运行qrencode -o test.bmp "hao",会不会生成二维码图片呢?依旧不会一帆风顺。

根据错误,push 两个库 \usr\lib\libpng16.so.16  \usr\lib\libqrencode.so.3,OK,生成二维码图片了。

接下来就应该不难了,修改bb文件,加install内容,根据相应内容生成二维码图片,对了,还有二维码大小。


这次难点主要是bitbake移植,自己弄了满满一天,最后都不用源码的configure.ac, Makefile.am等文件,自己写这些,但还是不得要领,移植失败。

然后请春神出马,不到半天,就搞定了。记之,学之。


你可能感兴趣的:(通过 bitbake 移植 qrencode 到嵌入式)