Click here to Skip to main content
14,326,008 members

Linux Programming

 
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 
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 
Vaclav_ wrote:
You are saying the problem is crosscompiling on X86 to ARM the resultant bluez "library", build on X86 by the process I am using , cannot be used.

That is correct. You do have a cross-compiler, so you could build the library using that compiler to get an ARM compatible library. In order to do that you would need to let make know to use the cross compiler. On my system that would be:
$ export CC=arm-linux-gnueabihf-gcc  CXX=arm-linux-gnueabihf-g++
$ configure --prefix=/usr/local/arm ...
$ make
$ sudo make install
Most packages use a configure, make, make install routine, but some use cmake to configure make. There's usually an install doc with any source tarball that will tell you how to build the package, and what dependencies are needed.

Vaclav_ wrote:
why am I getting "unable to find" - should the crosscomplier post a better descriptive error?

I'm not sure what you'd like the linker to do. When using the cross-compiler, that runs the cross-linker which looks in standard places and any provided search paths (-L flags) for the cross linker for libraries. The linker doesn't know whether -lbluetooth is a valid library name or not, just as it doesn't know if -lbleutoof is a valid library name or not.

Vaclav_ wrote:
I am under the impression that it is the purpose of crosscompliler - to manage DIFFERENT OS / hardware.

And that is what it is trying to do, but it does need target specific libraries to be able to complete its work.

Lets take a few steps back. Suppose we have the following code
$ cat hello.h
 #ifndef HELLO_H
 #define HELLO_H

void hello(void);

 #endif
$ cat hello.c
 #include <stdio.h>
 #include "hello.h"

void hello()
{
    printf("hello wolrd\n");
}
$ cat main.c 
 #include "hello.h"

int main()
{
    hello();
    return 0;
}
That's just a simple "hello world" C program broken up into 2 parts, a main.c and a hello.c with its associated hello.h

working on the X86 we can compile the pieces and then link in two steps as follows:
$ gcc -Wall -Wextra -c main.c hello.c
$ gcc main.o hello.o -o hello.x86
$ file *.o hello.x86 
hello.o:   ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
main.o:    ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
hello.x86: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=016de8ea587d3a1294bc3c2221aea11cba37c97f, not stripped
The -c tells gcc to compile the .c files and produce .o files, but don't link everything together. The linking we do in the second command, and all works as expected.
Now suppose we delete the main.o and try to use the cross-compiler to create a main.o and then link everything together:
$ rm main.o
$ arm-linux-gnu-gcc -Wall -Wextra -c main.c
$ file main.o hello.o
main.o:  ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
$ arm-linux-gnu-gcc main.o hello.o -o main.arm
/usr/bin/arm-linux-gnu-ld: i386:x86-64 architecture of input file `hello.o` is incompatible with arm output
/usr/bin/arm-linux-gnu-ld: hello.o: file class ELFCLASS64 incompatible with ELFCLASS32
/usr/bin/arm-linux-gnu-ld: final link failed: File in wrong format
collect2: error: ld returned 1 exit status
We can see that the format of the two .o files is different one is ELF-32bit for ARM and the other is ELF-64bit for X86_64. These are incompatible object formats, so we should not be surprised that they do not link together.
The difference between the simple hello.o file, above, and a library (either a .so or a .a) is that the library is, if you like, just a bundle of .o files. When linking to a library, what the linker does, in essence, is extract the object (.o) files from the library and links them into the executable (for shared libraries [.so files] its a little different, in that the linker only needs to insert into the executable the binding information for any called fuctions, but the idea is similar).

Vaclav_ wrote:
But all this is still done on X86 - only the result executable is passed to ARM.
OR is the linking done on ARM? That is confusing.

All the compiling and linking is done on the X86. If you were to shutdown the pi, the compilation and linking would still proceed in exactly the same manner.
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 
GeneralRe: Linking to library Pin
Vaclav_4-Mar-19 4:28
memberVaclav_4-Mar-19 4:28 
GeneralRe: Linking to library Pin
Richard MacCutchan4-Mar-19 4:56
protectorRichard MacCutchan4-Mar-19 4:56 

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.