Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Linking to bluetooth library - voluntarily moved from "quick answers" forum

Linking to bluetooth library - voluntarily moved from "quick answers" forum

Scheduled Pinned Locked Moved C / C++ / MFC
helpdiscussion
9 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am copying stuff from "quick answers" to here because it is no longer quick solution. I am doing voluntarily and will comment / post in FRONT and if I get discussion going here I will delete "quick answers". Last suggestion was to link to

    libbluetooth-dev

    Here is the SAME type of error - the library cannot be found. I am deleting most of the post - it is no longer needed.

    K L 3 Replies Last reply
    0
    • L Lost User

      I am copying stuff from "quick answers" to here because it is no longer quick solution. I am doing voluntarily and will comment / post in FRONT and if I get discussion going here I will delete "quick answers". Last suggestion was to link to

      libbluetooth-dev

      Here is the SAME type of error - the library cannot be found. I am deleting most of the post - it is no longer needed.

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      You appear to be trying to cross compile a project for a Raspberry Pi from a regular PC. The two CPUS do not share machine language, so you will need to install an arm version of libbluetooth to link against. There was another fellow that was trying to do this with the user name "Vaclav_", who's posts you should be able to search for. I don't know if he ever managed to get the cross comipilation working. In the short term, it might be more productive to develop on the RPI. If you have a RPI-4, then you've got a moderately powerful system. If you convert it to boot from USB using an SSD, it should be powerful and fast enough to get you started, while you research how to get an ARM-compatible libbluetooth installed.

      Keep Calm and Carry On

      1 Reply Last reply
      0
      • L Lost User

        I am copying stuff from "quick answers" to here because it is no longer quick solution. I am doing voluntarily and will comment / post in FRONT and if I get discussion going here I will delete "quick answers". Last suggestion was to link to

        libbluetooth-dev

        Here is the SAME type of error - the library cannot be found. I am deleting most of the post - it is no longer needed.

        K Offline
        K Offline
        k5054
        wrote on last edited by
        #3

        Part 2: You seem to be using Ubuntu, so you might be able to add packages via the multilib/foreign architecture options for apt. There's a discussion of it in the Debian Wiki here: [Multiarch/HOWTO - Debian Wiki](https://wiki.debian.org/Multiarch/HOWTO) I haven't tried this, so can't say for certain it will work, but if it does, it will be much easier than having to cross compile the libraries yourself.

        Keep Calm and Carry On

        1 Reply Last reply
        0
        • L Lost User

          I am copying stuff from "quick answers" to here because it is no longer quick solution. I am doing voluntarily and will comment / post in FRONT and if I get discussion going here I will delete "quick answers". Last suggestion was to link to

          libbluetooth-dev

          Here is the SAME type of error - the library cannot be found. I am deleting most of the post - it is no longer needed.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry about the long post - I have one more problem. I installed libbluetooth-dev on my ARM /RPi OS , used csp to copy to my X86 PC verified it exist on PC added -L to my options Still getting same error BUT the linker error is coming from different path and it definitely looks as the linker is NOT looking to the path I added

          -L/usr/lib/arm-linux-gnueabihf/arm-linux-gnueabihf' '-L/usr/lib/arm-linux-gnueabihf' '

          , but it is in verbose output Still missing something...

          OLLECT_GCC_OPTIONS='-L/usr/lib/x86_64-linux-gnu' '-L/usr/lib/arm-linux-gnueabihf/arm-linux-gnueabihf' '-L/usr/lib/arm-linux-gnueabihf' '-v' '-o' 'RPI_Bluetooth' '-shared-libgcc' '-march=armv6' '-mtune=arm1176jz-s' '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu'
          /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../libexec/gcc/arm-linux-gnueabihf/4.8.3/collect2 --sysroot=/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X -m armelf_linux_eabi -o RPI_Bluetooth /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/crt1.o /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/crti.o /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/crtbegin.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/arm-linux-gnueabihf/arm-linux-gnueabihf -L/usr/lib/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3 -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/lib -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/lib -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/lib

          K 1 Reply Last reply
          0
          • L Lost User

            Sorry about the long post - I have one more problem. I installed libbluetooth-dev on my ARM /RPi OS , used csp to copy to my X86 PC verified it exist on PC added -L to my options Still getting same error BUT the linker error is coming from different path and it definitely looks as the linker is NOT looking to the path I added

            -L/usr/lib/arm-linux-gnueabihf/arm-linux-gnueabihf' '-L/usr/lib/arm-linux-gnueabihf' '

            , but it is in verbose output Still missing something...

            OLLECT_GCC_OPTIONS='-L/usr/lib/x86_64-linux-gnu' '-L/usr/lib/arm-linux-gnueabihf/arm-linux-gnueabihf' '-L/usr/lib/arm-linux-gnueabihf' '-v' '-o' 'RPI_Bluetooth' '-shared-libgcc' '-march=armv6' '-mtune=arm1176jz-s' '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu'
            /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../libexec/gcc/arm-linux-gnueabihf/4.8.3/collect2 --sysroot=/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X -m armelf_linux_eabi -o RPI_Bluetooth /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/crt1.o /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/crti.o /home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/crtbegin.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/arm-linux-gnueabihf/arm-linux-gnueabihf -L/usr/lib/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3 -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/lib -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/lib -L/home/qw/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/lib

            K Offline
            K Offline
            k5054
            wrote on last edited by
            #5

            Firstly:

            OLLECT_GCC_OPTIONS='-L/usr/lib/x86_64-linux-gnu'

            That's a bit odd. If you are compiling for arm, you should not be including anything from the x86_64 lib tree. Secondly you seem to be confusing the difference between a software package, and its contents. The package is libbluetooh-dev. It has headers, documentation and other files that are needed to compile a program that uses libbluetooth. The package libbluetooth3 contains the shared library: /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.xx.yy, so you should ask to link only with -lbluetooth Thirdly: if you've installed the gcc cross-copmiler tools correctly, it should know how to find libm without any additional help from you. Consider the following very simple program

            #include
            #include

            int main()
            {
            printf("%f\n", lgamma(2.0));

            return 0;
            

            }

            In order to compile it, we need to include libm. On my X86-64 computer I do

            gcc example.c -o example -lm

            to create an x86-64 executable program. To create an ARM version I do

            gcc-arm7 example.c -o example-arm -lm

            I now have 2 versions of the example program, one for X86-64 and one for ARM e.g.

            k5054@loaclhost $ file example example-arm
            example: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c5d319f4b896ad825b708ff73a248ed23f64489f, for GNU/Linux 3.2.0, not stripped
            example-arm: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=1bc8369c7de09a7510c93c0bcab5824c6342d688, for GNU/Linux 3.2.0, not stripped

            Are you sure you've installed the cross compiler correctly and can produce simple programs (like example.c above or a basic hello world) that can run on the RPI?

            Keep Calm and Carry On

            L 1 Reply Last reply
            0
            • K k5054

              Firstly:

              OLLECT_GCC_OPTIONS='-L/usr/lib/x86_64-linux-gnu'

              That's a bit odd. If you are compiling for arm, you should not be including anything from the x86_64 lib tree. Secondly you seem to be confusing the difference between a software package, and its contents. The package is libbluetooh-dev. It has headers, documentation and other files that are needed to compile a program that uses libbluetooth. The package libbluetooth3 contains the shared library: /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.xx.yy, so you should ask to link only with -lbluetooth Thirdly: if you've installed the gcc cross-copmiler tools correctly, it should know how to find libm without any additional help from you. Consider the following very simple program

              #include
              #include

              int main()
              {
              printf("%f\n", lgamma(2.0));

              return 0;
              

              }

              In order to compile it, we need to include libm. On my X86-64 computer I do

              gcc example.c -o example -lm

              to create an x86-64 executable program. To create an ARM version I do

              gcc-arm7 example.c -o example-arm -lm

              I now have 2 versions of the example program, one for X86-64 and one for ARM e.g.

              k5054@loaclhost $ file example example-arm
              example: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c5d319f4b896ad825b708ff73a248ed23f64489f, for GNU/Linux 3.2.0, not stripped
              example-arm: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=1bc8369c7de09a7510c93c0bcab5824c6342d688, for GNU/Linux 3.2.0, not stripped

              Are you sure you've installed the cross compiler correctly and can produce simple programs (like example.c above or a basic hello world) that can run on the RPI?

              Keep Calm and Carry On

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              1. Being lazy I left the x86 links references in - it should not matter, but I'll take them out. 2. Yes I got puzzled by instruction to "install a library " when in essence I was installing a Linux package which contains the library and other stuff. I got better undertaking of thet now. 3. I have another app in works with no problem crosscompiling and actually running it on Raspberry. 3. No, I did not physically install the crosscomplier - just selected "cross compile" option in Eclipse. I am not sure if my -l and -L options are syntactically correct - but it looks OK in output I'll recheck that . Many thanks for your help, appreciate that very much.

              L 1 Reply Last reply
              0
              • L Lost User

                1. Being lazy I left the x86 links references in - it should not matter, but I'll take them out. 2. Yes I got puzzled by instruction to "install a library " when in essence I was installing a Linux package which contains the library and other stuff. I got better undertaking of thet now. 3. I have another app in works with no problem crosscompiling and actually running it on Raspberry. 3. No, I did not physically install the crosscomplier - just selected "cross compile" option in Eclipse. I am not sure if my -l and -L options are syntactically correct - but it looks OK in output I'll recheck that . Many thanks for your help, appreciate that very much.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Update 1. installing libbluetooth-dev package installs libbluetooth.a and libbluetooth.so AKA there is NO libbluetooth-dev library 2. linker options are -l:libbluetooth.a -L/usr/lib/x86_64-linux-gnu build process links and application runs as local , no crosscompiler, on "host" PC pre lang="text"> Building target: TEST_BT Invoking: GCC C++ Linker g++ -L/usr/lib/x86_64-linux-gnu -v -o "TEST_BT" ./src/TEST_BT.o -l:libbluetooth.a Using built-in specs. COLLECT_GCC=g++ Can anybody educate me about the ":" in -l**:**libbluetooth.a. I ADDED it in Eclipse options. WHY ?

                L 1 Reply Last reply
                0
                • L Lost User

                  Update 1. installing libbluetooth-dev package installs libbluetooth.a and libbluetooth.so AKA there is NO libbluetooth-dev library 2. linker options are -l:libbluetooth.a -L/usr/lib/x86_64-linux-gnu build process links and application runs as local , no crosscompiler, on "host" PC pre lang="text"> Building target: TEST_BT Invoking: GCC C++ Linker g++ -L/usr/lib/x86_64-linux-gnu -v -o "TEST_BT" ./src/TEST_BT.o -l:libbluetooth.a Using built-in specs. COLLECT_GCC=g++ Can anybody educate me about the ":" in -l**:**libbluetooth.a. I ADDED it in Eclipse options. WHY ?

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Member 14968771 wrote:

                  Can anybody educate me about the ":" in -l:libbluetooth.a.

                  I cannot find any reference to that option in Using the GNU Compiler Collection (GCC): Link Options[^], where the normal option would be -lbluetooth. I can only assume it is an add-on from somewhere that allows yo to specify the full library name.

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    Member 14968771 wrote:

                    Can anybody educate me about the ":" in -l:libbluetooth.a.

                    I cannot find any reference to that option in Using the GNU Compiler Collection (GCC): Link Options[^], where the normal option would be -lbluetooth. I can only assume it is an add-on from somewhere that allows yo to specify the full library name.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    It definitely looks as a linker "suggestion " when "libbluetooth" is set as an option When both ":" and ".a" are used linker does not complain. /usr/bin/ld: cannot find -llibbluetooth /usr/bin/ld: note to link with /usr/lib/x86_64-linux-gnu/libbluetooth.a use -l:libbluetooth.a or rename it to liblibbluetooth.a collect2: error: ld returned 1 exit status

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups