When I usually use code (include headers) from 3rd party (non-standard) C++ libraries, a pre-built binary file is linked to (or included in) the target executable that represents my application, but what happens with C++ standard library?, as far as I have seen I don't have to ship a library with an application that uses code only from the C++ standard library, thus is the code statically linked and included in the executable?
No, the standard libraries by default are dynamically linked at runtime.
When running the dynamic loader will look in a couple of standard places for dynamic libraries if it finds it loads and runs otherwise the application quits.
On Unix Systems:
/usr/lib: look for: libstdc++*
On Windows:
c:\windows\system32 look for: MSVCRT.DLL
There are also a couple of Environment variables that can affect the search path. Look at your platforms man page for dlopen to see what they are. Everything you need should be in the man pages for dlopen on your platform.
Most systems have these libs in the appropriate places and will automatically be found.
The rest of the STL will not introduces extra shared lib dependencies.
In recent MinGW gcc/g++ versions (4.40) you can link against a shared dll rather than the default static library by using the flag -shared-libstdc++.
The static versions of the library are located in /mingw/lib/gcc/mingw32/[gcc version]. The file name is libstdc++.a. This will be linked in by default when compiling a c++ app with MinGW.
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