简体   繁体   English

在Eclipse中链接蓝牙库bluez

[英]Linking bluetooth library bluez in eclipse

I want to compile and run the following bluetooth scan code bluetooth scan code on eclipse neon. 我想编译和运行下面的蓝牙扫描码蓝牙扫描代码 Eclipse的霓虹灯。

I need to run it on Raspberry pi 3, so I did the following: 我需要在Raspberry pi 3上运行它,所以我做了以下工作:

1- I downloaded the latest bluez version 5.43 from bluez 1-我从bluez下载了最新的bluez版本5.43

2- I compiled the downloaded file on my pi following the steps mentioned at Adafruit 2-我按照Adafruit中提到的步骤在pi上编译了下载的文件

3- I copied the compiled folder "bluez-5.43" from my Pi to the Pc to use it with eclipse. 3-我将已编译的文件夹“ bluez-5.43”从我的Pi复制到了PC,以便与Eclipse一起使用。 I am developing using Sysgcc cross compiling toolchain Cross Compiling on windows using SyssGcc toolchain 我正在使用Sysgcc交叉编译工具链进行开发在Windows上使用SyssGcc工具链进行交叉编译

4- I prepared the eclipse after installing the SyssGcc toolchain using the steps on Setting Up Cross-Compilation In Eclipse 4-我在SyssGcc工具链上安装Eclipse后,使用在Eclipse中设置交叉编译中的步骤进行了准备

5- I created a c++ project and copied the main code of the bluetooth mentioned in the first URL and went to: 5-我创建了一个c ++项目,并复制了第一个URL中提到的蓝牙的主要代码,然后转到:

Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes 项目>属性> C / C ++构建>设置> GCC C ++编译器>包含

In Include paths (-l) i add: .....\\bluez-5.43\\lib\\ 在包含路径(-l)中,我添加:..... \\ bluez-5.43 \\ lib \\

On eclipse Project > Properties > C/C++ Build > Settings > GCC C++ Linker > Libraries 在Eclipse项目>属性> C / C ++构建>设置> GCC C ++链接器>库中

In libraries (-l) i add: bluetooth 在库(-l)中,我添加:蓝牙

In Library search path (-L) i add: ....bluez-5.43\\lib.libs 在库搜索路径(-L)中,我添加:.... bluez-5.43 \\ lib.libs

but when I compile I get the following error, any help please for some one knows how to compile the code using eclipse and the cross compiling toolchain ?? 但是当我编译时出现以下错误,请提供任何帮助,因为有人知道如何使用eclipse和交叉编译工具链来编译代码?

    10:17:08 **** Incremental Build of configuration Debug for project Bluetooth_test ****
make all 
'Building target: Bluetooth_test'
'Invoking: Cross GCC Linker'
arm-linux-gnueabihf-gcc -L"C:\Users\aawad\Desktop\bluez-5.43\lib\.libs" -o "Bluetooth_test"  ./src/Bluetooth_test.o   -lbluetooth
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lbluetooth
collect2.exe: error: ld returned 1 exit status
make: *** [Bluetooth_test] Error 1

10:17:11 Build Finished (took 3s.57ms)

After several trials I was able to solve this error and the steps I mentioned above in the question are considered to be general preparation for some one wants to develop C using the Bluez Bluetooth protocol stack. 经过几次试验,我能够解决此错误,并且我在问题中上面提到的步骤被认为是某些人想要使用Bluez Bluetooth协议栈开发C的一般准备。

What worked out for me was: 对我有用的是:

Add the headers in the eclipse includes to make the CDT indexers know where the files are located 在eclipse include中添加标题,以使CDT索引器知道文件的位置

Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes 项目>属性> C / C ++构建>设置> GCC C ++编译器>包含

In Include paths (-l) i add: "C:\\Users\\aawad\\Desktop\\bluez-5.43\\lib" 在包含路径(-l)中,我添加:“ C:\\ Users \\ aawad \\ Desktop \\ bluez-5.43 \\ lib”

In the linking section: 在链接部分:

On eclipse Project > Properties > C/C++ Build > Settings > GCC C++ Linker > Libraries 在Eclipse项目>属性> C / C ++构建>设置> GCC C ++链接器>库中

In libraries (-l) i add: bluetooth-internal 在库(-l)中,我添加:蓝牙内部

In Library search path (-L) i add: "C:\\Users\\aawad\\Desktop\\bluez-5.43\\lib.libs" 在库搜索路径(-L)中,我添加:“ C:\\ Users \\ aawad \\ Desktop \\ bluez-5.43 \\ lib.libs”

compile and run the final executable on the Pi.. Turn your phone bluetooth and make it visible . 编译并在Pi上运行最终的可执行文件。将手机蓝牙设为可见。 You will find that the Pi can read your phone on the screen. 您会发现Pi可以在屏幕上读取您的手机。

上面的内容对我来说并不足够,要了解我所缺少的内容,我使用--disable-silent-rules配置了bluez(启用查看编译完整命令)-- --enable-testing (因此我可以看到与所需代码相似的代码)然后我运行make VERBOSE=1来查看所有需要的链接:lib / libbluetooth-internal.la src / libshared-glib.la -lglib-2.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM