docs/import_library.md
| Mode | Import Library | DLL (VS) | DLL (GitHub) |
|---|---|---|---|
| Release | msvcprt.lib | msvcp140.dll | msvcp140_oss.dll |
| Debug | msvcprtd.lib | msvcp140d.dll | msvcp140d_oss.dll |
An import library is a .lib file that defines its symbols as imported from a DLL.
Usually there is one .lib file for one .dll file, with the same name.
The names are different for MSVC because it started encoding its ABI version into the DLL's filename,
but there was no reason to change the import library's filename.
Also, an import library usually only contains references to DLL symbols and doesn't define anything on its own. However, this is purely a convention - nothing technically stops an import library from containing object files that are effectively statically linked.
This is what the STL's import library does - it defines some functions and variables on its own. This allows us to:
<filesystem> and much more.<charconv>'s lookup tables are a notable example.The caveats of this technique are:
/MD and /MDd options by embedding part of
the STL implementation into the resulting user binaries, rather than staying in the STL's DLL._ITERATOR_DEBUG_LEVEL.For these reasons, especially the last one, we need to strictly control what is used by the import library.
In particular, basic_string must not be used there.
Restricting the import library to including core headers only is an effective way to avoid problems.
locale0.cpp's inclusion of <xfacet> is currently a special case and should be treated with extreme caution.