在mini2440上移植Bluetooth


(参考:http://blog.csdn.net/guoxiaojie_415/article/details/5383898)

1.编译安装bluez-libs-3.36.tar.gz

sudo mkdir /opt/lib

sudo mkdir /opt/utils

这个库不需要什么依赖,直接解压,配置,编译然后安装即可。

#tar  zxvf  bluez-libs-3.36.tar.gz

#cdbluez-libs-3.36/

#./configure --prefix=/opt/lib--host=arm-linux --target=arm-linux CC=arm-linux-gcc

#sudomake 

#sudomake install

问题:../libtool:line 1311: arm-linux-gcc: command notfound

解答:(参考http://blog.csdn.net/sdwuyulunbi/article/details/6152437)

sudo-s

vim/etc/profile 添加:

exportPATH=$PATH:/home/hxy/FriendlyARM/wifi/opt/FriendlyARM/toolschain/4.4.3/bin

source/etc/profile

2.编译安装expat-2.0.1.tar.gz

tar xvzfexpat-2.0.1.tar.gz

cdexpat-2.0.1/

./configure  --prefix=/opt/lib--host=arm-linux  --target=arm-linux  CC=arm-linux-gcc
make
make install
或apt-get install libexpat1-dev
3.编译安装dbus-1.6.0.tar.gz
tarxvzf dbus-1.6.0.tar.gz
cd dbus-1.6.0/
#echoac_cv_have_abstract_sockets=yes>arm-linux.cache
#./configure --prefix=/opt/lib --host=arm-linux--target=arm-linux  CC="arm-linux-gcc-I/opt/lib/include -L/opt/lib/lib" --cache-file=arm-linux.cache--with-x=no
make
make install
4.编译安装glib-2.28.7.tar.bz2
tar xvjf glib-2.22.4.tar.bz2
cd glib-2.22.4/
vim arm-linux.cache 添加:
glib_cv_long_long_format=ll
glib_cv_stack_grows=no
glib_cv_working_bcopy=no
glib_cv_sane_realloc=yes
glib_cv_have_strlcpy=no
glib_cv_va_val_copy=yes
glib_cv_rtldglobal_broken=no
glib_cv_uscore=no
ac_cv_func_posix_getpwuid_r=yes
ac_cv_func_nonposix_getpwuid_r=no
ac_cv_func_posix_getgrgid_r=no
glib_cv_use_pid_surrogate=no
ac_cv_func_printf_unix98=no
ac_cv_func_vsnprintf_c99=no
ac_cv_path_GLIB_COMPILE_SCHEMAS=yes
./configure --prefix=/opt/lib--host=arm-linux--target=arm-linux        CC="arm-linux-gcc -I/opt/lib/include -L/opt/lib/lib"--cache-file=arm-linux.cache
make
make install
问题configure: error:
*** You must have either have gettext support in your C library, oruse the
*** GNU gettext library.(http://www.gnu.org/software/gettext/gettext.html
解答
:(参考http://blog.csdn.net/ybdesire/article/details/7249896
http://www.cnblogs.com/soli/archive/2008/01/14/1039010.html)
去http://www.gnu.org/software/gettext/gettext.httar xvzfgettext-0.18.3.tar.gzml下载gettext-0.18.3.tar.gz
cd gettext-0.18.3/
./configure  --prefix=/usr--host=arm-linux  --target=arm-linux  CC=arm-linux-gcc
make
make install
sudo vim /etc/ld.so.conf 添加有可能用到的库安装路径
/usr/local/lib
/opt/lib
ldconfig( 改动库文件后一定要运行一下)
问题configure:error: Could not find a glib-genmarshal in your PATH
解答:
(参考http://blog.chinaunix.net/uid-21931055-id-328766.html)
从http://rpm.pbone.net/index.php3/stat/4/idpl/2294397/dir/suse_8.x/com/glib2-devel-2.0.3-1.i386.rpm.html下载glib2-devel-2.0.3-1.i386.rpm
apt-get install rpm2cpio
rpm2cpio glib2-devel-2.0.3-1.i386.rpm | cpio-idm将在当前文件夹生成usr文件夹
cp -r usr /
问题:gsimpleaction.c: In function 'g_simple_action_class_init':
gsimpleaction.c:329: error: 'g_cclosure_marshal_VOID__VARIANT'undeclared (first use in this function)
gsimpleaction.c:329: error: (Each undeclared identifier is reportedonly once
gsimpleaction.c:329: error: for each function it appears in.)
解答:
(参考http://www.douban.com/note/216473248/
http://www.linuxdiyf.com/viewarticle.php?id=107892)
编译glib需要libffi,pkg-config, gettext。
安装zlib。从http://www.onlinedown.net/softdown/169854_2.htm下载zlib-1.2.5.tar.zip
unzip zlib-1.2.5.tar.zip
tar xvjf zlib-1.2.5.tar.bz2
cd zlib-1.2.5/
./configure
make
make install
whereis zlib.*  出现以下信息:(没有相应的路径,感觉没有安装成功。)
zlib:
zlib.3:
zlib:
zlib:
zlib:
zlib.pc:
apt-get install zlib1g-dev
# whereis zlib.*
zlib: /usr/include/zlib.h/usr/share/man/man3/zlib.3.gz
zlib.3: /usr/share/man/man3/zlib.3.gz
zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz
zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz
zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz
zlib.pc:
这次应该安装上了。
安装libffi。从http://www.mirrorservice.org/sites/sourceware.org/pub/libffi/下载libffi-3.0.11-rc2.tar.gz。
tar xvzf libffi-3.0.11-rc2.tar.gz
cd libffi-3.0.11-rc2/
./configure
make
make install
安装pkg-config。从http://download.chinaunix.net/download/0009000/8174.shtml下载pkgconfig-0.17.2.tar.bz2。
pkg-config --version
出现0.26 ,说明已经安装上了pkg-config。
whereis pkgconfig
出现pkgconfig: /usr/lib/pkgconfig /usr/local/lib/pkgconfig/usr/share/pkgconfig,同理,说明已经安装上了。
添加环境变量#vim /etc/profile
exportLIBFFI_CFLAGS=/usr/local/lib/libffi-3.0.11-rc2/
export LIBFFI_LIBS=/usr/local/lib/
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
#source/etc/profile
问题:(process:22906): GLib-Genmarshal-WARNING **:unknown type: VARIANT
(process:22906): GLib-Genmarshal-WARNING **: unknown type:VARIANT
(process:22906): GLib-Genmarshal-WARNING **: unknown type:VARIANT
(process:22906): GLib-Genmarshal-WARNING **: unknown type:VARIANT
(process:22906): GLib-Genmarshal-WARNING **: unknown type:VARIANT
(process:22906): GLib-Genmarshal-WARNING **: failed to open"--internal": No such file or directory
解答
:#vimgobject/stamp-gmarshal.h 注释 
//timestamp( 注意这里修改完,重新编译,居然又恢复了原样。离奇!!!)
//
#vim gobject/gmarshal.c
删掉文件开头的空行。
//
//
vim tests/gobject/stamp-testmarshal.h 新建文件
什么也不输入,保存退出。
(尚未解决该问题,愁!)
改用最新的glib-2.37.4,编译make,出现如下问题:
问题:.arm-none-linux-gnueabi-gcc: /usr/include/libffi-3.0.11-rc2/:No such file or directory
解答:
vimarm-linux.cache,把/usr/include/libffi-3.0.11-rc2/改成/usr/local/lib/libffi-3.0.11-rc2/
5.编译安装libusbx-1.0.16.tar.bz2
tar xvjflibusbx-1.0.16.tar.bz2
cd libusbx-1.0.16/
./configure --prefix=/opt/lib --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I/opt/lib/include-L/opt/lib/lib"
6.编译安装bluez-5.7.tar
xz -d bluez-5.7.tar.xz
tar xvf bluez-5.7.tar
cd bluez-5.7/
./configure --prefix=/opt/lib--host=arm-linux--target=arm-linux        CC="arm-linux-gcc -I/opt/lib/include -L/opt/lib/lib"--disable-audio

**************************************************************************************************
(有点做不下去了,环境变量,安装路径这些搞得一团糟,对于菜鸟级的我还是不继续这么走下去了,自己都绕晕了,改用http://blog.sina.com.cn/s/blog_7784d04f0100vrb3.html
http://blog.csdn.net/songjinshi/article/details/6520699的方式,做下来,挺顺畅的。)
首先将下载的所有包都放在bluetooth文件夹下。并在该文件夹下建立bluetooth-build文件夹,并将其输出到环境变量。

#cd  Bluetooth

#mkdir bluetooth-build

#blue=$PWD/bluetooth-build

#exportblue

#export   //检查是否包含blue环境变量:
declare -xblue="/home/hxy/FriendlyARM/bluetooth/bluetooth-build"
(#sudo -s //进入超级终端后面编译才不会出错
注意:千万别进入超级终端编译安装,很容易破坏系统的根文件。!!!)
1 、编译alsa-lib库

#tar xvjfalsa-lib-1.0.27.2.tar.bz2

#cd alsa-lib-1.0.27.2

#./configure --prefix=$blueCC=arm-linux-gcc --host=arm-linux --disable-python

#make

#make install

2、编译expat

#tar –zxvfexpat-2.0.1.tar.gz

#cd expat-2.0.1

#./configure --prefix=$blueCC="arm-linux-gcc -I$blue/include -L$blue/lib "--host=arm-linux

#make

#make install

3、编译D-Bus

#tar dbus-1.3.0.tar.gz

#cd  dbus-1.3.0

#echoac_cv_have_abstract_sockets=yes>arm-linux.cache

#./configure --prefix=$blue --host=arm-linux--target=arm-linux CC="arm-linux-gcc -I$blue/include-L$blue/lib"

#make

#make install

4、编译gettext

tar xvzfgettext-0.18.3.tar.gz

cd gettext-0.18.3/

./configure --prefix=$blue--host=arm-linux --target=arm-linux CC="arm-linux-gcc-I$blue/include -L$blue/lib"

make

make install

5、安装zlib
unzip zlib-1.2.5.tar.zip
tar xvjf zlib-1.2.5.tar.bz2

cdzlib-1.2.5/

(cp win32/Makefile.gcc Makefile
  ./configure --disable-shared--enable-static ;这里是编译动态库的例子。)

./configure--prefix=$blue
make
make install

6、编译libffi

tar xvzflibffi-3.0.11-rc2.tar.gz

cd libffi-3.0.11-rc2/
./configure --prefix=$blue --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I$blue/include -L$blue/lib"
make
make install
7、编译bluez-libs
tar xvzf bluez-libs-3.36.tar.gz
cd bluez-libs-3.36/
./configure --prefix=$blue --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I$blue/include -L$blue/lib"
make
make install
8、编译glib
tar xvjf glib- 2.28.6.tar.bz2
cd glib-2.28.6/
#vim arm-linux.cache 输入
(ac_cv_type_long_long=yes
glib_cv_stack_grows=no
glib_cv_uscore=no
ac_cv_func_posix_getpwuid_r=yes
ac_cv_func_posix_getgrgid_r=yes
或:)

glib_cv_long_long_format=ll

glib_cv_stack_grows=no

glib_cv_working_bcopy=no

glib_cv_sane_realloc=yes

glib_cv_have_strlcpy=no

glib_cv_va_val_copy=yes

glib_cv_rtldglobal_broken=no

glib_cv_uscore=no

ac_cv_func_posix_getpwuid_r=yes

ac_cv_func_nonposix_getpwuid_r=no

ac_cv_func_posix_getgrgid_r=no

glib_cv_use_pid_surrogate=no

ac_cv_func_printf_unix98=no

ac_cv_func_vsnprintf_c99=no

ac_cv_path_GLIB_COMPILE_SCHEMAS=yes

保存退出。

./configure --prefix=$blueCC="arm-linux-gcc -I$blue/include -L$blue/lib " --host=arm-linux--cache-file=arm-linux.cache

问题:configure: error: *** Youmust have either have gettext support in your C library, or usethe*** GNU gettext library.(http://www.gnu.org/software/gettext/gettext.html
解答:
sudo apt-get installgettext(发现前面第四个步骤没用,估计还是安装路径的问题。)

问题:configure: error: Could not find a glib-genmarshal inyour PATH

解答:apt-get install libglib2.0-dev

make

make install

9、编译libusb

从http://www.findthatzip-file.com/search-43797089-hZIP/winrar-winzip-download-libusb-1-0-8-tar-bz2.htm下载。

tar xvjflibusb-1.0.8.tar.bz2

cd libusb-1.0.8/

./configure --prefix=$blue--host=arm-linux --target=arm-linux CC="arm-linux-gcc-I$blue/include -L$blue/lib"

make
make install

10、编译byacc

从http://invisible-island.net/byacc/byacc.html#download下载。

tar xvzf byacc.tar.gz

cd byacc-20130304/
./configure --prefix=$blue CC="arm-linux-gcc -I$blue/include-L$blue/lib " --host=arm-linux

make
make install

或apt-get install byacc。

11、编译Flex

从http://linux.softpedia.com/progDownload/Flex-Download-23296.html下载。

tar xvjfflex-2.5.37.tar.bz2

cd flex-2.5.37/
./configure --prefix=$blueCC="arm-linux-gcc -I$blue/include -L$blue/lib "--host=arm-linux

make

make install

apt-get install flex更简单。

12、bluez-utils

从http://pkgs.fedoraproject.org/repo/pkgs/bluez-utils/bluez-utils-3.36.tar.gz/4fc292b635ba7b442c7aaf56 80199012/下载。
tar xvzf bluez-utils-3.36.tar.gz
cd bluez-utils-3.36/
./configure --prefix=$blue --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I$blue/include -L$blue/lib"--disable-audio
问题:configure: error: Bluetooth library is required
解答:apt-get installlibbluetooth-dev 
(参考:http://blog.csdn.net/do2jiang/article/details/4594716)
问题变成了:configure: error: D-Bus library is required
解答:apt-get install libdbus-1-dev libdbus-glib-1-dev
(参考http://www.360doc.com/content/12/1205/16/10388890_252294030.shtml)
make
问题:test -f lexer.c || /bin/bash ../ylwrap lexer.l .c lexer.c --/bin/bash /home/hxy/FriendlyARM/bluetooth/bluez-utils-3.36/missing--run flex 
make[3]: *** [lexer.c] 错误 1
解答
:--disable-audio
(参考http://mikewei.blog.51cto.com/1571146/312658)
问题:libhciserver.a(device.o):In function `get_properties':
device.c:(.text+0x146c): undefined reference to `g_malloc0_n'
libhciserver.a(device.o): In function `browse_cb':
device.c:(.text+0x1bbc): undefined reference to `g_malloc0_n'
libhciserver.a(dbus-service.o): In function `list_trusted':
dbus-service.c:(.text+0x400): undefined reference to`g_malloc_n'
libhciserver.a(dbus-service.o): In function`register_service':
dbus-service.c:(.text+0xab0): undefined reference to`g_malloc0_n'
libhciserver.a(dbus-sdp.o): In function`remote_svc_identifiers_completed_cb':
dbus-sdp.c:(.text+0x9c4): undefined reference to `g_malloc_n'
libhciserver.a(adapter.o): In function `adapter_list_trusts':
adapter.c:(.text+0x444): undefined reference to `g_malloc_n'
/home/hxy/FriendlyARM/my_build/opt/FriendlyARM/toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/../../../../arm-none-linux-gnueabi/bin/ld:warning: creating a DT_TEXTREL in object.
collect2: ld returned 1 exit status
make[3]: *** [hcid] 错误 1
make[3]:正在离开目录`/home/hxy/FriendlyARM/bluetooth/bluez-utils-3.36/hcid'
make[2]: *** [all] 错误 2
make[2]:正在离开目录`/home/hxy/FriendlyARM/bluetooth/bluez-utils-3.36/hcid'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录`/home/hxy/FriendlyARM/bluetooth/bluez-utils-3.36'
make: *** [all] 错误 2
12*、编译bluez-4.87
./configure --prefix=$blue CC="arm-linux-gcc-I$blue/include -L$blue/lib " --host=arm-linux
问题:configure: error:D-Bus library is required

解答
:sudo apt-get installlibdbus-1-devlibdbus-glib-1-dev(可见前面安装dbus也一样没效果。)
make
问题:tools/hcitool.c: In function'print_advertising_devices':
tools/hcitool.c:2306: error: 'EVT_LE_META_EVENT' undeclared (firstuse in this function)
tools/hcitool.c:2306: error: (Each undeclared identifier isreported only once
tools/hcitool.c:2306: error: for each function it appearsin.)
tools/hcitool.c:2316: error: 'evt_le_meta_event' undeclared (firstuse in this function)
tools/hcitool.c:2316: error: 'meta' undeclared (first use in thisfunction)
tools/hcitool.c:2317: error: 'le_advertising_info' undeclared(first use in this function)
tools/hcitool.c:2317: error: 'info' undeclared (first use in thisfunction)
tools/hcitool.c:2336: error: expected expression before ')'token
tools/hcitool.c: In function 'cmd_lescan':
tools/hcitool.c:2381: warning: implicit declaration of function'hci_le_set_scan_parameters'
tools/hcitool.c:2388: warning: implicit declaration of function'hci_le_set_scan_enable'
tools/hcitool.c: In function 'cmd_lecc':
tools/hcitool.c:2460: warning: implicit declaration of function'hci_le_create_conn'
13*.编译
libsndfile
从http://pkgs.fedoraproject.org/repo/pkgs/libsndfile/libsndfile-1.0.17.tar.gz/2d126c35448503f6dbe33934 d9581f6b/下载。
tar xvzflibsndfile-1.0.17.tar.gz
cd libsndfile-1.0.17/
./configure --prefix=$blue --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I$blue/include -L$blue/lib"
make
make install
14*、编译libxml
从http://linux.softpedia.com/progDownload/libxml2-Download-162.html下载。
tar xvzf libxml2-2.8.0.tar.gz
cd libxml2-2.8.0/
./configure --prefix=$blue --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I$blue/include -L$blue/lib" --without-zlib
make
make install
15*、 编译openobex
从http://download.chinaunix.net/download/0008000/7705.shtml下载。
tar xvzf openobex-1.2.tar.gz
cd openobex-1.2/
./configure --prefix=$blue --host=arm-linux --target=arm-linuxCC="arm-linux-gcc -I$blue/include -L$blue/lib" --enable-bluetooth--disable-usb --enable-apps
make
make install

***************************************************************************************************
气死!!!
一律用
./configure 
make
sudo makeinstall(这个会覆盖系统的安装文件,万万不能操作!!!)

结果编译都通过!
参考http://blog.sina.com.cn/s/blog_533074eb01011wp0.html
***************************************************************************************************
系统第三次重装。冷静!
想想我所要的无非bluez-4.87。只是它在编译过程中需要不少其他软件包而已。
直接进入bluez-4.87,编译:
./configure  CC=arm-linux-gcc--host=arm-linux
出现了 问题1:configure: error: C compiler cannot createexecutables
解答:安装arm-linux-gcc-4.4.3-20100728.tar.gz即可。
问题2:configure: error: D-Bus library is required
解答:apt-get install libdbus-1-devlibdbus-glib-1-dev
make
问题3:/home/hxy/opt/FriendlyARM/toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/../../../../arm-none-linux-gnueabi/bin/ld:cannot find -lglib-2.0
collect2: ld returned 1 exit status
解答: sudoapt-get install gettext
安装glib-2.22.4:
./configure CC=arm-linux-gcc --host=arm-linux--cache-file=arm-linux.cache
make
make install
出现问题:/bin/bash: 行 2: /usr/local/bin/glib-genmarshal:无法执行二进制文件
问题4:./ylwrap: 行 109: yacc: 未找到命令
解答:sudo apt-get install byacc
问题5:/home/hxy/FriendlyARM/bluetooth/bluez-4.87/missing: 行52: flex: 未找到命令
解答:sudo apt-get install flex

用./configure
make
都能通过,但下载指定的文件到开发板,并不能有预期效果:

1)     将bluetooth-build/sbin下的文件复制到开发板的/sbin下

#cp bluetooth-build/sbin/*   ROOTFS/sbin              //ROOTFS自己指定

#cp bluetooth-build/bin/hcitool        ROOTFS/bin/

#cp bluetooth-build/bin/rfcomm             ROOTFS/bin/

#cp bluetooth-build/bin/sdptool             ROOTFS/bin/

2)     复制相关的库到开发板的/lib下

#cp Bluetooth-build/lib/libbluetooth*   ROOTFS/lib        //ROOTFS自己指定

3)     复制配置文件到开发板的/etc目录下

#cp  -arfbluetooth-build/etc/bluetooth/   ROOTFS/etc/         //ROOTFS自己指定

理由很简单,因为和内核编译时所用的交互编译器不同。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值