Trouble compiling a shared library under linux
-
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
-
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
@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 theld
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.
-
@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 theld
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.
@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
-
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.
-
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.
-
@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.
-
@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 ?
-
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
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.
-
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.