I've noticed a failing with apps depending on shared libraries: that if you're missing some dependency, the app will fail at load time even if the user has no intention of using the dependency's functionality.
I'd like my apps to be better than that. Ideally, rather than distribute as many as n different packages, where n = numberOfSupportedArchitectures * numberOfSupportedOS * ∏(for each shared library)(the number of alternatives) I'd catch an "error while loading shared libraries" exception emitted at load time when the library I'd like- but don't need- is found to be absent, then continue execution in a way that simply avoids using the unresolved links concerned. But obviously there's no exception one can catch. If something's missing, it all falls down before main() even starts.
The closest I can get to having control over the loading process is resolving all the links myself with dlopen, dlsym and such. So tiresome. I'd expect there'd already be a library available to do that for me?
I note that this wouldn't be an issue on a source based distro nor on windows. I was going to put binary-packages in the tags but apparently I don't have the rep to coin tags.
'seems like the most elegant solution would lie in refining the behavior of OS's loader/linkers.
You can take a look at weak symbols. However, this is not a part of C or C++ standard - thus a bit dependent on the compiler. But if you are going for GCC, it's going to work for you, I guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With