Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trouble compiling a shared library under linux
Forum Updated to NodeBB v4.3 + New Features

Trouble compiling a shared library under linux

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 571 Views 2 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    I am new to shared libraries, I'm creating them with Qt5/C++/Linux. Sometimes they compile, sometimes they don't. I'm only making small changes to my .pro file. I just can't figure out what I changed.

    Can someone explain what this error means? (And how to fix it)

        /bin/ld: can not read symbols: file truncated
        /bin/ld: .eh_frame/.stab edit: file truncated
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.note.gnu.build-id' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gnu.hash' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.dynsym' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.dynstr' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gnu.version' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gnu.version_r' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.rela.dyn' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.rela.plt' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.init' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.plt' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.plt.got' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.text' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.fini' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.rodata' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.qtversion' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.eh_frame' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gcc_except_table' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.init_array' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.fini_array' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.data.rel.ro' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.dynamic' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.got' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.got.plt' not in segment
        /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.data' not in segment
        /bin/ld: final link failed: file truncated
        collect2: error: ld returned 1 exit status
    
    JonBJ 1 Reply Last reply
    0
    • ocgltdO ocgltd

      I am new to shared libraries, I'm creating them with Qt5/C++/Linux. Sometimes they compile, sometimes they don't. I'm only making small changes to my .pro file. I just can't figure out what I changed.

      Can someone explain what this error means? (And how to fix it)

          /bin/ld: can not read symbols: file truncated
          /bin/ld: .eh_frame/.stab edit: file truncated
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.note.gnu.build-id' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gnu.hash' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.dynsym' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.dynstr' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gnu.version' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gnu.version_r' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.rela.dyn' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.rela.plt' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.init' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.plt' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.plt.got' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.text' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.fini' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.rodata' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.qtversion' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.eh_frame' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.gcc_except_table' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.init_array' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.fini_array' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.data.rel.ro' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.dynamic' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.got' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.got.plt' not in segment
          /bin/ld: animal_00000100.so.1.0.0: warning: allocated section `.data' not in segment
          /bin/ld: final link failed: file truncated
          collect2: error: ld returned 1 exit status
      
      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @ocgltd said in Trouble compiling a shared library under linux:

      Sometimes they compile, sometimes they don't.

      Um, that's not good!

          /bin/ld: can not read symbols: file truncated
      

      I presume a file handed to ld is empty/corrupt/incorrect/not what it's supposed to be. You would at least need to show what the ld command line is to begin to guess.

      And if you are "only making small changes to my .pro file" and that changes from linking to not working you might show that/those too.

      ocgltdO 1 Reply Last reply
      0
      • JonBJ JonB

        @ocgltd said in Trouble compiling a shared library under linux:

        Sometimes they compile, sometimes they don't.

        Um, that's not good!

            /bin/ld: can not read symbols: file truncated
        

        I presume a file handed to ld is empty/corrupt/incorrect/not what it's supposed to be. You would at least need to show what the ld command line is to begin to guess.

        And if you are "only making small changes to my .pro file" and that changes from linking to not working you might show that/those too.

        ocgltdO Offline
        ocgltdO Offline
        ocgltd
        wrote on last edited by ocgltd
        #3

        @JonB I discovered that the error occurs when compile 2 shared libraries at the same time. They share a lot of the same .h/.cpp files, so it looks like one job is writing output files while the other is trying to read them.

        Restricting to 1 .so compile avoids the error. But that doesn't sound like the right solution.

        Is there a way to help Qmake not try to compile the same .cpp in two jobs at the same time? I saw the config+=ordered option, but it is "discouraged"...not sure what options there are

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          How do you trigger these two parallel builds ?

          On a side note, if they share so much of the same sources, it would likely be better to have three libraries. One core library that contains the common code and then the two others that use it.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          ocgltdO 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            How do you trigger these two parallel builds ?

            On a side note, if they share so much of the same sources, it would likely be better to have three libraries. One core library that contains the common code and then the two others that use it.

            ocgltdO Offline
            ocgltdO Offline
            ocgltd
            wrote on last edited by ocgltd
            #5

            @SGaist I have a .pro file of template type libs, so QMake seems to start compiling multiple sourcedirs at once.

            In time I may split the .so...but for where I am on the learning curve I just want to keep it simple.

            SGaistS 1 Reply Last reply
            0
            • ocgltdO ocgltd

              @SGaist I have a .pro file of template type libs, so QMake seems to start compiling multiple sourcedirs at once.

              In time I may split the .so...but for where I am on the learning curve I just want to keep it simple.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @ocgltd you have mentioned building multiple libraries at the same time, a .pro file can only build one project so the situation is not clear.

              Can you explain exactly how you are doing things ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              ocgltdO 1 Reply Last reply
              0
              • SGaistS SGaist

                @ocgltd you have mentioned building multiple libraries at the same time, a .pro file can only build one project so the situation is not clear.

                Can you explain exactly how you are doing things ?

                ocgltdO Offline
                ocgltdO Offline
                ocgltd
                wrote on last edited by
                #7

                I have the project's main .pro file which uses template = subdirs. I then have one .pro for my app, and one .pro for EACH library.

                So it's all part of one project, but that project builds one app and many libraries

                SGaistS 1 Reply Last reply
                0
                • ocgltdO ocgltd

                  I have the project's main .pro file which uses template = subdirs. I then have one .pro for my app, and one .pro for EACH library.

                  So it's all part of one project, but that project builds one app and many libraries

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Then my original suggestion still applies: rather than duplicating symbols in several libraries, keep the common parts in one and link it to the others.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  ocgltdO 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Then my original suggestion still applies: rather than duplicating symbols in several libraries, keep the common parts in one and link it to the others.

                    ocgltdO Offline
                    ocgltdO Offline
                    ocgltd
                    wrote on last edited by
                    #9

                    @SGaist I will have to do that to clean up the build process. At this points it's more curiosity than anything else.

                    Since I set CONFIG+=ordered in the libs.pro file I assumed that each library .pro would be built in series. Yet it doesn't seem to do so.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved