环境说明:
编译平台:在Ubuntu16.04.1上使用buildroot-2017.08
编译结果运行平台:armv7l架构芯片,Linux内核版本4.9.84
bluez版本:bluez-5.46
整体思路:直接编译bluez包,根据buildroot的提示,一步一步添加编译bluez所需要的各个依赖
1、查看buildroot-2017.08/package/bluez5_utils/Config.in(这只是我的目录,你根据自己的目录对应起来,后面的目录也要对应到自己的目录,以后不再说明)
第一行如下:
config BR2_PACKAGE_BLUEZ5_UTILS
说明要编译bluez5则对应要把buildroot/.config文件里的BR2_PACKAGE_BLUEZ5_UTILS设为y
在buildroot-2017.08/.config文件里找的合适位置,设置 BR2_PACKAGE_BLUEZ5_UTILS=y,我设置的位置对应如下
1654 # Networking applications
1655 #
1656 # BR2_PACKAGE_AICCU is not set
1657 # BR2_PACKAGE_AIRCRACK_NG is not set
1658 # BR2_PACKAGE_APACHE is not set
1659 # BR2_PACKAGE_ARGUS is not set
1660 # BR2_PACKAGE_ARP_SCAN is not set
1661 # BR2_PACKAGE_ARPTABLES is not set
1662 # BR2_PACKAGE_ATFTP is not set
1663 # BR2_PACKAGE_AVAHI is not set
1664 # BR2_PACKAGE_AXEL is not set
1665 # BR2_PACKAGE_BABELD is not set
1666 # BR2_PACKAGE_BANDWIDTHD is not set
1667 # BR2_PACKAGE_BATCTL is not set
1668 # BR2_PACKAGE_BCUSDK is not set
1669 # BR2_PACKAGE_BIND is not set
1670 # BR2_PACKAGE_BLUEZ_TOOLS is not set
1671 # BR2_PACKAGE_BLUEZ_UTILS is not set
1672 BR2_PACKAGE_BLUEZ5_UTILS=y
然后在buildroot-2017.08下执行make
2、make后提示如下
Makefile:539: *** dbus is in the dependency chain of bluez5_utils that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in。 停止。
Makefile:79: recipe for target ‘_all’ failed
解决:查看buildroot-2017.08/package/bluez5_utils/bluez5_utils.mk文件
发现依赖dbus,如下:
BLUEZ5_UTILS_DEPENDENCIES = dbus libglib2
所以要把buildroot下的.config里的dbus功能对应项设为y
查看buildroot-2017.08/package/dbus/Config.in
找到dbus功能的对应名为 BR2_PACKAGE_DBUS 如下:
config BR2_PACKAGE_DBUS
修改buildroot下的.config文件
找到文件里BR2_PACKAGE_DBUS 项,原为:
修改为:
BR2_PACKAGE_DBUS =y
然后继续make编译
3、make后提示
Makefile:539: *** libglib2 is in the dependency chain of bluez5_utils that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in。 停止。
解决方法如2
4、继续make提示
Makefile:539: *** expat is in the dependency chain of dbus that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in。 停止。
解决方法如2
5、继续make提示
Makefile:539: *** libffi is in the dependency chain of libglib2 that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in。 停止。
解决方法如2
6、继续make提示
Makefile:539: *** pcre is in the dependency chain of libglib2 that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in。 停止
解决方法如2
7、继续make提示
Makefile:539: *** util-linux is in the dependency chain of libglib2 that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in。 停止。
解决方法如2
8、继续make提示
bsdiff (BR2_PACKAGE_BSDIFF) [N/y/?] n
bustle (BR2_PACKAGE_BUSTLE) [N/y/?] (NEW) aborted!
Console input/output is redirected. Run ‘make oldconfig’ to update configuration.
这个问题是因为buildroot下.config文件里没有BR2_PACKAGE_BUSTLE项,BR2_PACKAGE_BUSTLE是新的,buildroot不知道该把它设置为什么,
解决:在.config文件里找到BR2_PACKAGE_BSDIFF项,在它下面添加
即可
继续编译
9、继续make提示
dbus (BR2_PACKAGE_DBUS) [Y/n/?] y
dbus-c++ (BR2_PACKAGE_DBUS_CPP) [N/y/?] (NEW) aborted!
解决方法如8
10、继续make提示
dbus-c++ (BR2_PACKAGE_DBUS_CPP) [N/y/?] n
dbus-glib (BR2_PACKAGE_DBUS_GLIB) [N/y/?] (NEW) aborted!
解决方法如8
、
、
、
等等
只要是这类问题就按照8的方法解决,然后解决n多个类似问题后就可以正常编译了
编译时如果你的buildroot/dl目录里没有刚才你添加的各个编译项对应的资源包如 dbus-1.10.22.tar.gz、glib-2.52.2.tar.xz等
那么在编译时buildroot会根据你在对应的 .mk 文件里设置的 ***_SITE的值去对应地址下载
如dbus.mk文件里的:
DBUS_VERSION = 1.10.22
DBUS_SITE = https://dbus.freedesktop.org/releases/dbus
libglib2.mk文件里的:
LIBGLIB2_VERSION_MAJOR = 2.52
LIBGLIB2_VERSION = ( L I B G L I B 2 V E R S I O N M A J O R ) . 2 L I B G L I B 2 S O U R C E = g l i b − (LIBGLIB2_VERSION_MAJOR).2 LIBGLIB2_SOURCE = glib- (LIBGLIB2VERSIONMAJOR).2LIBGLIB2SOURCE=glib−(LIBGLIB2_VERSION).tar.xz
LIBGLIB2_SITE = http://ftp.gnome.org/pub/gnome/sources/glib/$(LIBGLIB2_VERSION_MAJOR)
你也可以手动下载下来放到buildroot/dl目录下,不过版本要和对应的.mk文件里的一样
11、还有一个比较重要的错误,如果提示如下错误:
gconvert.c:59:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv
#error GNU libiconv not in use but included iconv.h is from libiconv
这个需要修改 /buildroot/package/libglib2/libglib2.mk 文件,在 HOST_LIBGLIB2_CONF_OPTS 选项最后添加
–disable-iconv
–with-libiconv=gnu
(注意:要在原来HOST_LIBGLIB2_CONF_OPTS 选项的最后一行加上 \,这个符号是连接行的意思)
我的如下:
HOST_LIBGLIB2_CONF_OPTS = \
--disable-coverage \
--disable-dtrace \
--disable-fam \
--disable-libelf \
--disable-selinux \
--disable-systemtap \
--disable-xattr \
--with-pcre=system \
--disable-iconv \
--with-libiconv=gnu
然后buildroot编译顺利完成
注意:我所添加的新的编译包,如我新添加了dbus包的编译,在我的buildroot环境上本来就有dbus包的编译规则,也就是我的环境在buildroot//package目录里有dbus这个文件夹,并且dbus文件夹里有对应的文件,我的dbus目录如下
package/dbus$ ls
0001-config-loader-expat-Tell-Expat-not-to-defend-against.patch Config.in dbus.hash dbus.mk S30dbus
如果你添加的编译包在你的buildroot环境里没有对应的编译规则,那你需要在package目录下新建对应的编译规则文件