編譯bluez-5.25 通過 Linux環境下運行

來源:互聯網
上載者:User

標籤:bluetooth   bluez-5.25   

本次編譯的是bluez 5版本以上的,之前的版本不支援藍芽4.0,只有5版本以上支援4.0.我的Linux宿主機是Ubuntu14.04版本

本次編譯參考http://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BlueZ_Bluetooth_tools_for_ARMhttp://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BlueZ_Bluetooth_tools_for_ARM

在這個基礎上還做了一些小修改,避免一些錯誤。好開始記錄步驟,比較繁瑣,O(∩_∩)O。這裡也對原文做一些解釋。

zlib-1.2.8

zlib的編譯不需要指定--host,但是後面配置完成後需要修改Makefile檔案,以進行交叉編譯。

源碼:wget http://zlib.net/zlib-1.2.8.tar.gz

配置:./configure --prefix=/wsh_space/my_install/bluez5

修改Makefile:

CC=arm-cortex_a9-linux-gnueabi-gcc
LDSHARED=arm-cortex_a9-linux-gnueabi-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
CPP=arm-cortex_a9-linux-gnueabi-gcc -E
AR=arm-cortex_a9-linux-gnueabi-ar
RANLIB=arm-cortex_a9-linux-gnueabi-ranlib

編譯:

make

make install


libffi-3.0.13

源碼:wget ftp://sourceware.org/pub/libffi/libffi-3.0.13.tar.gz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5

編譯:

make

make install


glib-2.40.0

編譯glib依賴zlib, libffi and glibc >= 2.18,宿主機若是Ubuntu14.04,glibc的版本為2.19,這裡是滿足的。另外很可能會缺少glib-genmarshal ,我編譯時間是缺少了,這個好解決,執行命令

sudo apt-get install libglib2.0-dev
安裝即可。下面是具體的步驟:

源碼:wget http://ftp.gnome.org/pub/gnome/sources/glib/2.40/glib-2.40.0.tar.xz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5 PKG_CONFIG_PATH=/wsh_space/my_install/bluez5/lib/pkgconfig  glib_cv_stack_grows=no glib_cv_uscore=yes ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes

編譯:

make

make install


D-Bus

D-Bus daemon會需要expat XML parser 庫,所以這裡需要先編譯expat庫。如果不安裝會出現下面的錯誤:

checking for XML_ParserCreate_MM in -lexpat... noconfigure: error: Explicitly requested expat but expat not found

步驟如下

expat-2.1.0

源碼:wget http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5

編譯:

make

make install


D-Bus1.9.4

在使用原文中的配置時,編譯會報錯,如下:

corrupt.c:29:18: fatal error: glib.h: 沒有那個檔案或目錄
/wsh_space/my_install/bluez5/include/glib-2.0/glib.h:30:26: fatal error: glib/galloca.h: 沒有那個檔案或目錄
fatal error: glibconfig.h: 沒有那個檔案或目錄

經過查看,是test目錄下檔案引用的.h檔案路徑不正確,可以一個一個修改路徑,但是相當繁瑣。

我的方法是,屏蔽test,增加--disable-tests選項。

源碼:wget http://dbus.freedesktop.org/releases/dbus/dbus-1.9.4.tar.gz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5 --disable-tests

編譯:

make

make install


libical-1.0

bluez的編譯需要libical的支援,編譯libical需要cmake和g++,所以系統中需要這兩個工具,可以運行下面兩個命令進行安裝,需要保持網路暢通。

sudo apt-get install cmake
sudo apt-get install g++-arm-linux-gnueabi

然後就可進行編譯安裝了

源碼:wget http://downloads.sourceforge.net/freeassociation/libical-1.0.tar.gz

配置: export CC=arm-cortex_a9-linux-gnueabi-gcc
export CXX=arm-linux-gnueabi-g++
cmake -DCMAKE_INSTALL_PREFIX=/wsh_space/my_install/bluez5

注意這裡的命令是直接在命令列執行的。

編譯:

make

make install


Readline

編譯readline是需要ncurses的支援,如果沒有ncurses,編譯時間會報下面的錯誤。

/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `PC'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `tgetflag'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `tgetent'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `UP'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `tputs'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `tgoto'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `tgetnum'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `BC'/usr/arm-linux-gnueabi/lib/libreadline.so: undefined reference to `tgetstr'
引用ncurses的方法是,在make時添加SHLIB_LIBS=-lncurses選項


ncurses-5.9

源碼:wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5 CXX="arm-linux-gnueabi-g++"

編譯:

make

make install


Readline6.3

配置時需要添加bash_cv_wcwidth_broken=yes選項,避免出現下面的錯誤:

checking for wcwidth broken with unicode combining characters... configure: error: in `/.../readline-6.3':configure: error: cannot run test program while cross compiling

源碼:wget ftp://ftp.cwru.edu/pub/bash/readline-6.3.tar.gz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5 bash_cv_wcwidth_broken=yes

編譯:

make SHLIB_LIBS=-lncurses

make install


Building BlueZ

bluez包含了藍芽所需的基本工具,如hciattach, hciconfig, hcitool and rfcomm等。

BlueZ 5.25 至少需要 GLib >= 2.28, D-Bus >= 1.6 and libudev >= 143,由於linudev是個相當麻煩的東西,為此在編譯bluez時,把它給屏蔽了即可。

源碼:wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.25.tar.xz

配置:./configure --host=arm-cortex_a9-linux-gnueabi --prefix=/wsh_space/my_install/bluez5 PKG_CONFIG_PATH=/wsh_space/my_install/bluez5/lib/pkgconfig CC="arm-cortex_a9-linux-gnueabi-gcc -L/wsh_space/my_install/bluez5/lib -I/wsh_space/my_install/bluez5/include" --disable-systemd --disable-udev --disable-cups --disable-obex --enable-library

編譯:

make 

make install DESTDIR=/wsh_space/my_install/bluez5

注意這裡的安裝會產生一個特殊的檔案,如所示:


在使用dbus-daemon時,是需要這個檔案的,這個檔案的結構如:


另外還需要把安裝目錄下的var檔案夾拷貝到wsh_space/my_install/bluez5目錄 下,如:


在開發板使用時,需要把wsh_space檔案夾拷貝到系統的根目錄下。

還需要一些庫檔案,我時直接把整個安裝目錄拷貝到開發板的/usr/local/bluetooth下。

到此,完成,其他的測試可以參考原文。



編譯bluez-5.25 通過 Linux環境下運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.