歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> ARM上交叉編譯藍牙Bluez

ARM上交叉編譯藍牙Bluez

日期:2017/3/1 10:11:41   编辑:Linux編程

應好友的求助,幫忙編譯bluez
我的機器環境 Ubuntu 10.04
arm-none-linux-gnueabi-gcc 4.3.3

源碼下載的地方:
http://pkgs.fedoraproject.org/repo/pkgs/

dbus-1.2.16.tar.gz download

Bluez交叉編譯移植到arm linux .
Version:

Bluez:3.36

Gcc :arm-linux-gcc-3.4.1

所需軟件包:

libxml2-2.7.4

dbus1.0.2

glib-2.16.5

bluez-utils-3.36依賴於dbus和glib,而dbus依賴於libxml2,所以編譯順序是libxml,dbus,glib,bluez-utils-3.36.

流程寫的簡單,其實在我自己的編譯過程中出現了無數的問題,只是都簡化到配置裡面去了,所以configuare一定要配置好.

1.編譯bluez-libs-3.36

./configure --host=arm-linux --prefix="$PWD/../release/bluez_libs"
make&make install
沒有什麼依賴庫的問題,直接編譯通過.

2.編譯libxml2-2.7.4

./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux
make
make install

沒有依賴庫,順利通過

3.編譯dbus1.0.2

echo ac_cv_have_abstract_sockets=yes>arm-linux.cache
./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux CC="arm-linux-gcc -I/home/jay/tools/bluez3/release/bluez_libs/include -L/home/jay/tools/bluez3/release/bluez_libs/lib" --cache-file=arm-linux.cache --with-x=no
--with-xml=libxml PKG_CONFIG_PATH="$PWD/../release/bluez_libs/lib/pkgconfig"
make&make install
順利通過了

4.編譯glib-2.16.5

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_getgrgid_r=yes>>arm-linux.cache
echo ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache
./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux CC="arm-linux-gcc -I/home/jay/tools/bluez3/release/bluez_libs/include
-L/home/jay/tools/bluez3/release/bluez_libs/lib" --cache-file=arm-linux.cache PKG_CONFIG_PATH="$PWD/../release/bluez_libs/lib/pkgconfig"
#make
#make install

5.編譯bluez-utils-3.36.
./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux CC="arm-linux-gcc -I/home/jay/tools/bluez3/release/bluez_libs/include -L/home/jay/tools/bluez3/release/bluez_libs/lib -shared" PKG_CONFIG_PATH="$PWD/../release/bluez_libs/lib/pkgconfig" --disable-audio --enable-test

make&make install

如果不追加-shared,會出現很討厭的__fini_array_start錯誤.

遇到storage.c:286: error: error: `ENOKEY' undeclared
修改storage.c 增加#define ENOKEY 161

至此bluez編譯完畢.


文件系統的制作:

將sbin和bin下的文件復制進文件系統的sbin下面,lib文件需要的有

libbluetooth.so
libbluetooth.so.2 libbluetooth.so.2.11.2

libxml2.so
libxml2.so.2 libxml2.so.2.7.4

libglib-2.0.so
libglib-2.0.so.0 libglib-2.0.so.0.1600.5

libgmodule-2.0.so.0 libgmodule-2.0.so.0.1600.5

前面是軟鏈接,後面是本尊

將etc文件夾復制過去.

最後記得把hcidump(需要另外編譯,沒有任何難度)復制到sbin,它方便調試的

以下是Leeu我的編譯遇到 的問題.

libusb 要用到g++
./configure --prefix=/opt/libs --host=arm-linux CC="arm-none-linux-gnueabi-gcc" CXX=arm-none-linux-gnueabi-g++

dbus的編譯,把下面整個一起執行

USE_ARCH=32 NM=nm CC="arm-none-linux-gnueabi-gcc ${BUILD32}" ./configure --prefix=/opt/libs --host=arm-linux --target=arm-linux CC="arm-none-linux-gnueabi-gcc -I/opt/libs/include -L/opt/libs/lib" --cache-file=arm-linux.cache --with-x=no
否則會報libtool中 eval的錯誤

4.編譯glib-2.16.5

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_getgrgid_r=yes>>arm-linux.cache
echo ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache


./configure --prefix=/opt/libs --host=arm-linux CC="arm-none-linux-gnueabi-gcc -I/opt/libs/include -L/opt/libs/lib" --cache-file=arm-linux.cache PKG_CONFIG_PATH=/opt/libs/lib/pkgconfig

#make
#make install

buluz-utils
./configure --prefix=/opt/libs --host=arm-linux CC="arm-none-linux-gnueabi-gcc -I/opt/libs/include -L/opt/libs/lib -shared" PKG_CONFIG_PATH=/opt/libs/lib/pkgconfig --disable-audio
去掉--enable-test
過程會報找不到yacc, flex等命令,安裝命令即可

這樣就編譯好了。

Copyright © Linux教程網 All Rights Reserved