You are not logged in.
I'm facing a strange problem when compiling my software. I have an executable which links various shared libraries, and everything works fine in Arch. Compiling under Ubuntu with gcc 4.8.2 I notice that a library which is correctly listed in the linker invocation command is not linked to the executable. There is no error, but ldd shows that that library has not been linked. I checked that the ld options are the same under Arch and Ubuntu, so the linker invocation is exactly the same but the results differ.
Since the library in question is a plugin library which I decide to link to my executable instead of loading it at runtime (because I always use the code in it), in my executable there is no direct reference to the code in the library (the plugin uses a proxy class to automatically register itself to a factory). So I wonder if ld could possibly decide to not link a library which contains code which apparently is never executed. I searched the web but I found no clear statement about this.
Thanks.
p.s. I know that someone might feel inappropriate to ask on Arch forums about a problem that shows up in Ubuntu. However, I think that my question is more related to the behavior of ld than to a Ubuntu specific issue, so I decided to post it here (I always got great answers from the people in this forum and moreover Arch is my main system). Anyway, I apologize in advance if this post is considered inappropriate for Arch forums.
Offline
Ubuntu ships static libs, Arch (mostly) doesn't.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Thanks WorMzy, but the libraries and executables I'm talking about are all parts of a project of mine, not components shipped by the distribution. The whole project is built using cmake.
Offline
Are you building with makepkg on arch? If so, it's likely due to the '--as-needed' LDFLAG.
EDIT: oops - it seems I missread. It behaves as expected on arch, but not on ubuntu? If the `ld` that ships with Ubuntu is not behaving as expected or documented, how is that not a ubuntu specific issue?
Last edited by Trilby (2014-12-27 00:46:17)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Hi Trilby, my guess is that in certain situations ld might behave as I described, and that this behavior is not a Ubuntu specific issue even if it shows up in Ubuntu inn my case. I'm not sure about his, like I'm not sure if my problem is really due to this supposed behavior.
Anyway, if you feel that this thread is out of scope please close it.
Offline