交叉编译bluez-5.47
参考:https://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BlueZ_Bluetooth_tools_for_ARM
https://blog.youkuaiyun.com/JiYeon67/article/details/79042742
前提:交叉编译的文件放在/home/brook/bluez5/build_out下,要有个根文件系统在:/home/brook/bluez5/rootf
编译zlib-1.2.11
CC=arm-linux-gnueabihf-gcc ./configure --prefix=/home/brook/bluez5/build_out
# make
# make install
编译expat-2.1.0
# ./configure --prefix=/home/brook/bluez5/build_out --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
# make
# make install
编译libffi-3.0.13
# ./configure --prefix=/home/brook/bluez5/build_out --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
# make
# make install
编译glib-2.40.0
./configure \
--prefix=/home/brook/bluez5/build_out \
--host=arm-linux-gnueabihf \
--target=arm-linux-gnueabihf \
CC=arm-linux-gnueabihf-gcc \
PKG_CONFIG_PATH=/home/brook/bluez5/build_out/lib/pkgconfig \
glib_cv_stack_grows=no \
glib_cv_uscore=yes \
glib_cv_have_qsort_r=yes \
ac_cv_func_posix_getpwuid_r=yes \
ac_cv_func_posix_getgrgid_r=yes
# make
# make install
编译dbus-1.9.4
./configure \
--prefix= \
--host=arm-linux-gnueabihf \
--target=arm-linux-gnueabihf \
CC=arm-linux-gnueabihf-gcc \
--with-x=no \
--disable-tests \
--enable-abstract-sockets \
CFLAGS=-I/home/brook/bluez5/build_out/include \
LDFLAGS=-L/home/brook/bluez5/build_out/lib
# make
# make install DESTDIR=/home/brook/bluez5/build_out
# make install DESTDIR=/home/brook/bluez5/rootf
编译libical-1.0
# ./bootstrap
# ./configure --prefix=/home/brook/bluez5/build_out --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
# make
# make install
编译readline-6.3
# ./configure --prefix=/home/brook/bluez5/build_out --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc bash_cv_wcwidth_broken=yes
# make
# make install
编译ncurses-5.9
# ./configure --prefix=/home/brook/bluez5/build_out --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --with-shared
# make
# make install
编译bluez-5.47
./configure \
--prefix= \
--host=arm-linux-gnueabihf \
--target=arm-linux-gnueabihf \
CC=arm-linux-gnueabihf-gcc \
PKG_CONFIG_PATH=/home/brook/bluez5/build_out/lib/pkgconfig \
CFLAGS="-I/home/brook/bluez5/build_out/include -I/home/brook/bluez5/build_out/include/glib-2.0 -I/home/brook/bluez5/build_out/include/dbus-1.0" \
LDFLAGS="-L/home/brook/bluez5/build_out/lib -lncurses -lreadline -ldbus-1 -lglib-2.0 -lical" \
DBUS_CFLAGS=-I/home/brook/bluez5/build_out/lib/dbus-1.0/include \
DBUS_LIBS=-L/home/brook/bluez5/build_out/lib \
GLIB_CFLAGS=-I/home/brook/bluez5/build_out/lib/glib-2.0/include \
GLIB_LIBS=-L/home/brook/bluez5/build_out/lib \
ICAL_CFLAGS=-I/home/brook/bluez5/build_out/include \
ICAL_LIBS=-L/home/brook/bluez5/build_out/lib \
--disable-udev \
--disable-obex \
--enable-library \
--enable-experimental \
--mandir=/home/brook/bluez5/build_out/man \
--disable-systemd
# make
# make install DESTDIR=/home/brook/bluez5/build_out
make install DESTDIR=/home/brook/bluez5/rootf
install -v -dm755 /home/brook/bluez5/rootf/etc/bluetooth
install -v -m644 src/main.conf /home/brook/bluez5/rootf/etc/bluetooth/main.conf
将根文件系统拷贝到开发板上,执行:
# dbus-launch
# /libexec/bluetooth/bluetoothd & //如果出错,缺啥库拷贝啥库就好了, -C为兼容模式,为了sdptool browse local能够执行
#bluetoothctl //进交互模式操作
[bluetooth]# power on //上电
[bluetooth]# show //查看本控制器信息
[bluetooth]# pair 48:46:C1:40:9D:E6 //配对