Linux兵工厂

V1

2022/11/23阅读:16主题:草原绿

zynq平台蓝牙协议栈移植

zynq平台蓝牙协议栈移植

  • 虚拟机环境:Ubuntu16.04.3

编译安装bluez-libs-3.36

./configure --prefix=/opt/bluez/bluez-libs-3.36 --host=arm-linux --target=arm-linux CC=arm-linux-gnueabihf-gcc
make
sudo make install

编译安装expat-2.5.0

./configure --prefix=/opt/bluez/expat-2.5.0 --host=arm-linux --target=arm-linux CC=arm-linux-gnueabihf-gcc
make
sudo make install

编译安装dbus-1.15.2

./configure --prefix=/opt/bluez/dbus-1.15.2 --host=arm-linux --target=arm-linux CC="arm-linux-gnueabihf-gcc -lexpat -I/opt/bluez/expat-2.5.0/include -L/opt/bluez/expat-2.5.0/lib" --cache-file=arm-linux.cache --with-x=no --enable-tests=no
make
sudo make install

#
错误
checking for EXPAT... configure: error: Package requirements (expat) were not met:
No package 'expat' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables EXPAT_CFLAGS
and EXPAT_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
#解决
export EXPAT_CFLAGS=/opt/bluez/expat-2.5.0/bin
export EXPAT_LIBS=/opt/bluez/expat-2.5.0/lib

编译zlib-1.2.13

注:当前的configure文件是没有选项参数可供我们配置使用,只能配置生成Makefile后,修改Makefile。

./configure

vi Makefile
# 这里的交叉编译工具(arm-none-linux-gnueabi-),大家要根据自己的实际情况来定,可能名字不一样
CROSS_COMPILE=arm-none-linux-gnueabi-
CC=$(CROSS_COMPILE)gcc
LDSHARED=$(CROSS_COMPILE)gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
CPP=$(CROSS_COMPILE)gcc -E
AR=$(CROSS_COMPILE)ar
RANLIB=$(CROSS_COMPILE)ranlib
prefix =${HOME}/zlib

make

make install

编译安装glib-2.26.1

echo ac_cv_type_long_long=yes>arm-linux.cache
echo glib_cv_stack_grows=no>>arm-linux.cache
echo glib_cv_uscore=no>>arm-linux.cache
echo ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache
echo ac_cv_func_posix_getgrgid_r=yes>>arm-linux.cache

./configure --prefix=/opt/bluez/glib-2.26.1 --host=arm-linux --target=arm-linux CC="arm-linux-gnueabihf-gcc -I/opt/bluez/dbus-1.15.2/include -I/opt/bluez/bluez-libs-3.36/include -I/opt/bluez/expat-2.5.0/include -L/opt/bluez/dbus-1.15.2/lib -L/opt/bluez/bluez-libs-3.36/lib -L/opt/bluez/expat-2.5.0/lib -I/opt/bluez/zlib-1.2.13/include -L/opt/bluez/zlib-1.2.13/lib" CXX=arm-linux-gnueabihf-g++ --cache-file=arm-linux.cache
make
make install

#
错误
gzlibcompressor.c:28:10: fatal error: zlib.h: No such file or directory
#include <zlib.h>
解决
交叉编译zlib库,并指定路径-I/opt/bluez/zlib-1.2.13/include -L/opt/bluez/zlib-1.2.13/lib

编译安装bluez-utils-3.36

#注意生成的Makefile中的路径
export DBUS_CFLAGS = -I/opt/bluez/dbus-1.15.2/include/dbus-1.0 -I/opt/bluez/dbus-1.15.2/lib/dbus-1.0/include
export GLIB_CFLAGS = -I/opt/bluez/glib-2.26.1/include/glib-2.0
#如果make时报头文件不存在,则查看链接的头文件路径是否正确,是否是检查编译的库的路径

./configure --prefix=/opt/bluez/bluez-utils-3.36 --host=arm-linux --target=arm-linux CC="arm-linux-gnueabihf-gcc -I/opt/bluez/dbus-1.15.2/include/dbus-1.0 -I/opt/bluez/dbus-1.15.2/lib/dbus-1.0/include -I/opt/bluez/bluez-libs-3.36/include -I/opt/bluez/expat-2.5.0/include -L/opt/bluez/dbus-1.15.2/lib -L/opt/bluez/bluez-libs-3.36/lib -L/opt/bluez/expat-2.5.0/lib -I/opt/bluez/zlib-1.2.13/include -L/opt/bluez/zlib-1.2.13/lib -I/opt/bluez/glib-2.26.1/include/glib-2.0 -I/opt/bluez/glib-2.26.1/lib/glib-2.0/include -L/opt/bluez/glib-2.26.1/lib" --disable-audio
make
make install

拷贝至目标板

#copy /opt/arm/bluez/sbin/* 到你的文件系统/sbin

cp bluez/sbin/*   /sbin/

#
copy /opt/arm/bluez/bin/ 下的 hcitool,rfcomm,sdptool 到你的文件系统 /bin

cp bluez/bin/*    /bin/

#
copy /opt/arm/bluez/lib/* 到文件系统的/lib下 

#
copy /opt/arm/bluez/etc/bluetooth/* 到你的文件系统 /etc

cp bluez/etc/bluetooth  /etc/

分类:

后端

标签:

操作系统

作者介绍

Linux兵工厂
V1

高级Linux软件工程