Click here to Skip to main content
14,272,574 members

Linux Programming

 
QuestionSOLVED Developing bluetooth app using "bluez" package (FROM SOURCE ) Pin
Vaclav_5-Mar-19 5:18
memberVaclav_5-Mar-19 5:18 
AnswerRe: Developing bluetooth app using "bluez" Pin
Richard MacCutchan5-Mar-19 6:32
protectorRichard MacCutchan5-Mar-19 6:32 
GeneralRe: Developing bluetooth app using "bluez" Pin
Vaclav_5-Mar-19 6:46
memberVaclav_5-Mar-19 6:46 
GeneralRe: Developing bluetooth app using "bluez" Pin
Richard MacCutchan5-Mar-19 6:50
protectorRichard MacCutchan5-Mar-19 6:50 
GeneralRe: Developing bluetooth app using "bluez" Pin
Vaclav_5-Mar-19 9:03
memberVaclav_5-Mar-19 9:03 
GeneralRe: Developing bluetooth app using "bluez" Pin
Richard MacCutchan5-Mar-19 22:45
protectorRichard MacCutchan5-Mar-19 22:45 
GeneralRe: Developing bluetooth app using "bluez" Pin
Vaclav_5-Mar-19 7:39
memberVaclav_5-Mar-19 7:39 
AnswerRe: Developing bluetooth app using "bluez" Pin
k50545-Mar-19 9:44
memberk50545-Mar-19 9:44 
5. At this point the linker , actually cross linker , references to anything "bluetooth"  such as "-lbluethooth" or "-libbluetooth"  yields  " not found " cross linker error. 

There's the problem. On your X86_64 box, you've installed bluez-X86_64. The linker will not link an X86_64 lib into an ARM target. Your X86_64 linux distribution may provide a libbluetooth-devel-arm package that will work with the cross compiler, but I doubt that.

I've just been poking about on my rpi-2 (raspian-debian jessie), and I think the following might work for you. Note that if you're on a pi3 or using something other jessie, things will be slightly different.

on the pi:
sudo apt-get install -d libbluetooth-dev
The -d flag downloads the package and puts it in /var/cache/apt/archives/, but doesn't actually install it. I see there's a lot of files there, so it might be worth checking to see if you've already got the package there already. On my system its libbluetooth-dev_5.23-2+rpi2_armhf.deb, so I expect yours will be similar.

on the X86_64, we'll assume that you've got a $HOME/tmp that you will use for copying and you will put the package contents in $HOME/rpi. Vary as necessary in the following:
cd $HOME/tmp 
scp pi@10.0.1.76:/var/cache/apt/archives/libbluetooth-dev_5.23-2+rpi2_armhf.deb
mkdir $HOME/rpi
cd $HOME/rpi
dpkg -x $HOME/tmp/libbluetooth-dev_5.23-2+rpi2_armhf.deb
This will unpack the contents of the libbluetooth-dev package in the current directory. You should now have usr/include, usr/lib and usr/share in the $HOME/rpi directory, and you can now remove $HOME/tmp/libbluetooth-dev_5.23-2+rpi2_armhf.deb file. If you check your $HOME/rpi/lib/arm-linux-gnueabihf directory, you will probably find a broken link for libbluetooth.so. If you're happy just using the static linked .a library, you can delete the broken link. If you'd like to use the shared library, then scp /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.17.1 from the pi to $HOME/pi/lib/arm-linux-gnueabeihf (once again things may be different if you're on a different OS version than me).

Now add flags for -I $HOME/rpi/usr/include and -L$HOME/rpi/usr/lib/arm-linux-gnueabihf -lbluetooth to your IDE. (check the last part of the -L path if not on jessie). This way, at least, you have the same includes and libs available to your cross compiler as you have on the pi, but you'll have to remember to update the X86_64 if you update the bluetooth package on the pi.

Now, I haven't tried this, beyond unpacking the pi package (on the pi...) so it might not work, but I think it should. If there are any dependencies that libbluetooth-dev has that are needed, you'll need to repeat this process with them, too.

If this doesn't work, you may have to use the crosscompiler to build libbluetooth (and any of its dependencies).

Update:
I have had a chance to try this out, and can confirm it should work. Not knowing where to start with libbluetooth, I wrote a short ncurses program which I was able to cross-compile using the technique above and run on my rpi. I did run into an issue where libncurses has a dependency on libtinfo, so I had to track that down and add it to my $HOME/rpi, so you may have to do the same with any dependencies libbluetooth might have.

modified 5-Mar-19 20:22pm.

GeneralRe: Developing bluetooth app using "bluez" Pin
Vaclav_5-Mar-19 13:37
memberVaclav_5-Mar-19 13:37 
GeneralRe: Developing bluetooth app using "bluez" Pin
k50546-Mar-19 6:57
memberk50546-Mar-19 6:57 
GeneralRe: Developing bluetooth app using "bluez" Pin
Vaclav_5-Mar-19 16:02
memberVaclav_5-Mar-19 16:02 
GeneralRe: Developing bluetooth app using "bluez" Pin
k50546-Mar-19 8:50
memberk50546-Mar-19 8:50 
GeneralRe: Developing bluetooth app using "bluez" Pin
Vaclav_6-Mar-19 11:58
memberVaclav_6-Mar-19 11:58 
QuestionLinking to library Pin
Vaclav_3-Mar-19 5:22
memberVaclav_3-Mar-19 5:22 
AnswerRe: Linking to library Pin
Richard MacCutchan3-Mar-19 5:53
protectorRichard MacCutchan3-Mar-19 5:53 
GeneralRe: Linking to library Pin
Vaclav_3-Mar-19 7:08
memberVaclav_3-Mar-19 7:08 
AnswerRe: Linking to library Pin
k50543-Mar-19 6:03
memberk50543-Mar-19 6:03 
GeneralRe: Linking to library Pin
Vaclav_3-Mar-19 7:09
memberVaclav_3-Mar-19 7:09 
AnswerRe: Linking to library Pin
k50543-Mar-19 6:32
memberk50543-Mar-19 6:32 
GeneralRe: Linking to library Pin
Vaclav_3-Mar-19 7:05
memberVaclav_3-Mar-19 7:05 
AnswerRe: Linking to library Pin
Vaclav_3-Mar-19 7:15
memberVaclav_3-Mar-19 7:15 
GeneralRe: Linking to library Pin
k50543-Mar-19 7:44
memberk50543-Mar-19 7:44 
GeneralRe: Linking to library Pin
Vaclav_3-Mar-19 8:12
memberVaclav_3-Mar-19 8:12 
GeneralRe: Linking to library Pin
k50543-Mar-19 9:04
memberk50543-Mar-19 9:04 
GeneralRe: Linking to library Pin
Richard MacCutchan3-Mar-19 21:34
protectorRichard MacCutchan3-Mar-19 21:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.