3 ms·
This is only true when statically linking. Order does not matter when dynamically linking. (This was a surprise to me but I have tested it.)
by wpollock 1y ago
This is only true when statically linking. Order does not matter when dynamically linking. (This was a surprise to me but I have tested it.)
- bluGill 1y agoOrder matters if you violating the one definiton rule - the first one wins one linux. This is illegal undefined behavior that doesn't work on windows and I don't know what mac does. hopefully this is useless trivia.
- o11c 1y agoI'm pretty sure distro-specific spec files can make it matter. But you really, really should be using `pkg-config` (and no other obsolete `foo-config`) so you don't have to worry about it regardless. (If you really want to do it yourself, learn about the `tsort` program first. Although allegedly obsolete for its original purpose, it is still useful to automate some sanity, and applies just as well between libraries as within them.)
- cozzyd 1y agoThis depends on the default value of the -as-needed linker options. Fedora/red hat and debian/Ubuntu diverge here
- wpollock 1y agoGood to know, thanks! I only tested on Fedora. If anyone cares, here's a link for a tarball for testing this; read the simple makefile for details: <https://wpollock.com/AUnix2/dll-demo.tgz https://wpollock.com/AUnix2/dll-demo.tgz> (I wrote this long ago, as a linking demo for system administration students.)