3 ms·
Linux and Windows have very different dynamic linking strategies. (I think Windows does it better…)
by forrestthewoods 3y ago
Linux and Windows have very different dynamic linking strategies. (I think Windows does it better…)
- cryptonector 3y ago> (I think Windows does it better…) Tell us more?
- forrestthewoods 3y agoImagine you have a .cpp file with a global variable. Now imagine this cpp file is compiled into two different shared/dynamic libraries. And that both are loaded by some exe. On Linux you’ll have one global variable. On Windows each DLL will have its own copy. Which is better? It depends. Personally I think it’s much better for each shared/dynamic library to be a black box with a clearly defined API boundary. Thus I think the Windows approach is better. The root evil here is that C++ is underdefined and what should really really really be a language level rule is actually left up to the platform. I also think globals are evil and should almost never be used. But that’s a separate topic.
- cryptonector 3y agoYou missed the above commentary. If you use versioned symbols then the right thing will happen on Linux too: each shared object will have its own copy. > The root evil here is that C++ is underdefined and what should really really really be a language level rule is actually left up to the platform. Well, the issue is that C++ shares linking semantics with C, and C's linking semantics are not that well specified, because there's static linking -broken- and ELF -which has evolved to fix the problem you mention-.
- forrestthewoods 3y agoI read the commentary. Linux has eleventy billion config settings. If you very carefully set them, maintain them, and make regular blood moon sacrifices you can induce the desired behavior. I think the Windows model is better. I think Linux generally handles shared libraries poorly. You probably love Linux and think its preferences are great. That’s fine.
- cryptonector 3y agoThis is not a system configuration setting. This is a matter of linker-editor defaults. Those defaults tend to be bad for backwards compatibility reasons. Yes, if you build software on Linux (or the BSDs, or Solaris, or Illumos distros) you have to know about this, or use frameworks that do.
- forrestthewoods 3y agoThe thing about defaults is that anyone can change them. It’s easy! Also Google pays $26,000,000,000 a year to make sure Google is the default search engine. Because defaults are so easy to change that nobody changes them. The Linux software community expects libraries to be written a certain way. It is a de facto platform configuration setting. Even if there are, per Linux tradition, a few flags.