One of the many key differences between C++ Compilers GCC & MSVC is that in the first all symbols from a shared library are exported by default, while MSVC exports nothing.
Some implications are that in, In MSVC, you have to export explict instantiated template classes.
While I have accepted this as a fact of life, I was wondering what are the design implications, trade offs, from a compiler designer perspective, etc. of each approach?
It probably has something to do with what executables and libraries are in their respective OS's.
On Windows, both libraries (DLL) and executables are the same thing. Literally, you can rename a .dll to .exe and it will run the protected mode stub and output some error (again, protected mode, so it will only work on a 16-bit system). Given that they're the same, and you can (and do!) export symbols from actual executables, you'd expect the default to be to export nothing right?
On Linux however, executables are their own thing, and code libraries (shared objects, .so) are something else. In fact .so files are closer to archives (.a, sort of gcc libraries -- but are not actually archives) if I recall correctly. There's no need for a .lib to be included to use the shared library like in Windows because it is a library file of sorts. Given that you're explicitly compiling your output as this shared library, I don't really see anything weird with it just exporting everything by default.
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