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 libraries - follow-up- gcc++ won't link

Linking libraries - follow-up- gcc++ won't link

Scheduled Pinned Locked Moved C / C++ / MFC
c++helplinux
10 Posts 4 Posters 2 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.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    Hope it is OK to make new post. I am still working on this assumption:

    other
    An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

    Adding full path to desired library to be added to existing library resolved the "cannot find " issue. Now the gcc++ needs to be told to actually link, contrary to the "other" instruction taken from Linux documentation. I get same error when using libbluetooth.a.

    'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
    Finished building: ../MODULE/M_TEST/CTEST.cpp

    g++: warning: /usr/lib/x86_64-linux-gnu/bluetooth: linker input file unused because linking not done

    Building file: ../MODULE/M_SOCKET/CSOCKETCOMMON.cpp
    Invoking: GCC C++ Compiler

    L K CPalliniC V 5 Replies Last reply
    0
    • V Vaclav_

      Hope it is OK to make new post. I am still working on this assumption:

      other
      An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

      Adding full path to desired library to be added to existing library resolved the "cannot find " issue. Now the gcc++ needs to be told to actually link, contrary to the "other" instruction taken from Linux documentation. I get same error when using libbluetooth.a.

      'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
      Finished building: ../MODULE/M_TEST/CTEST.cpp

      g++: warning: /usr/lib/x86_64-linux-gnu/bluetooth: linker input file unused because linking not done

      Building file: ../MODULE/M_SOCKET/CSOCKETCOMMON.cpp
      Invoking: GCC C++ Compiler

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

      You need to show us the command you are using to do the build. The message above suggests that you are only invoking the compile of some source module(s), so no library is needed.

      1 Reply Last reply
      0
      • V Vaclav_

        Hope it is OK to make new post. I am still working on this assumption:

        other
        An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

        Adding full path to desired library to be added to existing library resolved the "cannot find " issue. Now the gcc++ needs to be told to actually link, contrary to the "other" instruction taken from Linux documentation. I get same error when using libbluetooth.a.

        'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
        Finished building: ../MODULE/M_TEST/CTEST.cpp

        g++: warning: /usr/lib/x86_64-linux-gnu/bluetooth: linker input file unused because linking not done

        Building file: ../MODULE/M_SOCKET/CSOCKETCOMMON.cpp
        Invoking: GCC C++ Compiler

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

        Some very odd things here:

        Vaclav_ wrote:

        'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'

        That looks wrong. That looks like your compiler command could be boiled down to

        g++ CTEST.o -o CTEST.o

        You're passing in and producing the same .o file, not creating an executable, only an intermediate object. In which case the g++ warning makes sense, since its telling you that the lib wasn't used to create the .o file. In which case you should be getting a g++ fatal error input file is same as output file. Second thing is the warning itself. The path given is /usr/lib/x86_64-linux-gnu/bluetooth. Normally that would be libbluetooth.a. In which case the linker should be able to pick it up as -lbluetooth, since its in the expected location. It just doesn't have a name format that the linker recognizes as a library. I'd say say something messed up when installing the library, if this is indeed the case and you've not just messed up copying the output from your system to the forum.

        1 Reply Last reply
        0
        • V Vaclav_

          Hope it is OK to make new post. I am still working on this assumption:

          other
          An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

          Adding full path to desired library to be added to existing library resolved the "cannot find " issue. Now the gcc++ needs to be told to actually link, contrary to the "other" instruction taken from Linux documentation. I get same error when using libbluetooth.a.

          'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
          Finished building: ../MODULE/M_TEST/CTEST.cpp

          g++: warning: /usr/lib/x86_64-linux-gnu/bluetooth: linker input file unused because linking not done

          Building file: ../MODULE/M_SOCKET/CSOCKETCOMMON.cpp
          Invoking: GCC C++ Compiler

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          As already noted by k5054, you (-o option) are asking the g++ to NOT perform the linking step. Nevermind. (thanks to k5054)

          In testa che avete, signor di Ceprano?

          K 1 Reply Last reply
          0
          • CPalliniC CPallini

            As already noted by k5054, you (-o option) are asking the g++ to NOT perform the linking step. Nevermind. (thanks to k5054)

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

            Oops, Ha Ha, actually, we both got that wrong. The compiler is quite happy to link an executable into a file named foo.o e.g.

            $ g++ hello.cpp -o hello.o
            $ ./hello.o
            Hello World!
            $

            Its the -c option that compiles but does not link, so that must have been included in the command sent to the compiler.

            CPalliniC 1 Reply Last reply
            0
            • V Vaclav_

              Hope it is OK to make new post. I am still working on this assumption:

              other
              An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

              Adding full path to desired library to be added to existing library resolved the "cannot find " issue. Now the gcc++ needs to be told to actually link, contrary to the "other" instruction taken from Linux documentation. I get same error when using libbluetooth.a.

              'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
              Finished building: ../MODULE/M_TEST/CTEST.cpp

              g++: warning: /usr/lib/x86_64-linux-gnu/bluetooth: linker input file unused because linking not done

              Building file: ../MODULE/M_SOCKET/CSOCKETCOMMON.cpp
              Invoking: GCC C++ Compiler

              V Offline
              V Offline
              Vaclav_
              wrote on last edited by
              #6

              Stand-by. I build some more test apps and "discovered" that type .so library has STANDARD IDE options for linker , but type .a , which I have been messing with, does NOT. Also neither one of them show -l option, only -L. Basically - forget IDE, back to GCC raw options.

              L 1 Reply Last reply
              0
              • V Vaclav_

                Stand-by. I build some more test apps and "discovered" that type .so library has STANDARD IDE options for linker , but type .a , which I have been messing with, does NOT. Also neither one of them show -l option, only -L. Basically - forget IDE, back to GCC raw options.

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

                Vaclav_ wrote:

                type .so library has STANDARD IDE options for linker , but type .a , which I have been messing with, does NOT.

                That makes no sense, there are no such things as standard IDE options for compiling and/or linking. The options are determined by the specific compiler and linker in use. You may have an IDE that is set up to use the most common options for gcc, but you still need to modify it depending whether you are trying to create a static archive (.a), or shared object library (.so).

                1 Reply Last reply
                0
                • K k5054

                  Oops, Ha Ha, actually, we both got that wrong. The compiler is quite happy to link an executable into a file named foo.o e.g.

                  $ g++ hello.cpp -o hello.o
                  $ ./hello.o
                  Hello World!
                  $

                  Its the -c option that compiles but does not link, so that must have been included in the command sent to the compiler.

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Yes, of course you are right. Thank you for pointing out.

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • V Vaclav_

                    Hope it is OK to make new post. I am still working on this assumption:

                    other
                    An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

                    Adding full path to desired library to be added to existing library resolved the "cannot find " issue. Now the gcc++ needs to be told to actually link, contrary to the "other" instruction taken from Linux documentation. I get same error when using libbluetooth.a.

                    'MODULE/M_TEST/CTEST.o' '-o' 'MODULE/M_TEST/CTEST.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
                    Finished building: ../MODULE/M_TEST/CTEST.cpp

                    g++: warning: /usr/lib/x86_64-linux-gnu/bluetooth: linker input file unused because linking not done

                    Building file: ../MODULE/M_SOCKET/CSOCKETCOMMON.cpp
                    Invoking: GCC C++ Compiler

                    V Offline
                    V Offline
                    Vaclav_
                    wrote on last edited by
                    #9

                    Post-mortem FYI SOLVED(?) 1.Both projects ( IDE terminology) works as expected. NOT REALLY SURE WHY. 2.The “mother” executable - project has -lbluetooth -lRPI_BT_LIB, but ONLY -L "${workspace_loc:/RPI_BT_LIB/Debug}" optioned. 3. There are NO references / options to “bluetooth” in RPI_BT_LIB, only source includes. 3. Adding “bluetooth” as per this ( no -l or -L !) other An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way. Creates “cannot find ...” error 4. Adding “/usr/…/bluetooth” creates “ did not link ...” error but has no effect on processing. (It was pointed out that GCC was not optioned to link ) 5. running “make clear” idefinites full library file name - “libRPI_RT_LIB.a” 6. Using “standard IDE” ( I am calling IDE UI form "standard" ) to build type .a library gives NO linking options, however building .so gives ALL options. 7. Using “standard IDE form” to build a project – executable or library – creates “system” default includes. NOT sure if they are used only for source or linking libraries. As far as I can tell this whole mess was because I could not tell if I was using wrong GCC options or wrong syntax It was NEVER about (-l / -L ). The unanswered question remains - how does the RPI_BT_LIB library manages to use "bluetooth" library.

                    L 1 Reply Last reply
                    0
                    • V Vaclav_

                      Post-mortem FYI SOLVED(?) 1.Both projects ( IDE terminology) works as expected. NOT REALLY SURE WHY. 2.The “mother” executable - project has -lbluetooth -lRPI_BT_LIB, but ONLY -L "${workspace_loc:/RPI_BT_LIB/Debug}" optioned. 3. There are NO references / options to “bluetooth” in RPI_BT_LIB, only source includes. 3. Adding “bluetooth” as per this ( no -l or -L !) other An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way. Creates “cannot find ...” error 4. Adding “/usr/…/bluetooth” creates “ did not link ...” error but has no effect on processing. (It was pointed out that GCC was not optioned to link ) 5. running “make clear” idefinites full library file name - “libRPI_RT_LIB.a” 6. Using “standard IDE” ( I am calling IDE UI form "standard" ) to build type .a library gives NO linking options, however building .so gives ALL options. 7. Using “standard IDE form” to build a project – executable or library – creates “system” default includes. NOT sure if they are used only for source or linking libraries. As far as I can tell this whole mess was because I could not tell if I was using wrong GCC options or wrong syntax It was NEVER about (-l / -L ). The unanswered question remains - how does the RPI_BT_LIB library manages to use "bluetooth" library.

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

                      Vaclav_ wrote:

                      how does the RPI_BT_LIB library manages to use "bluetooth" library.

                      The same way that any code uses any library. Define the external references and add the library to the build process. Take a look at gcc library - Google Search[^] for more detailed information.

                      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