We are using a third-party library in our Visual Studio 2013 C++ project. This library I guess uses a different STL library than ours. We are getting some link errors. There are no compile-time errors. As I understand, STL is primarily template-based code thus requiring no linking. Looks like there are some parts of STL that do require linking with an STL library. Wondering if there is a way to force STL to be completely inline. Regards.
2 Answers
There is no single answer to this question. In general, C++ is well known to not be "link-compatible" (or "binary compatible") between different versions of compilers (or different brands of compilers, etc, etc). So someone supplying a library SHOULD specify exactly which compiler they expect to be used, and the user of the library will need to use that one. [I've even seen problems using exactly the same version, but two different "builds" of the compiler]
To POSSIBLY find a solution, you'd have to look at what it is the compiler/linker is attempting to find, and then see if that function is at all present in the sources for the STL - if it is, then possibly applying a liberal sprinkling (on the relevant functins) of "always_inline" or whatever that particular compiler uses for that functionality. But chances are that the functions you're missing aren't provided in the header files in the first place. This of course assumes that you actually have the source for the library, so that it can be recompiled [or you can convince the provider to recompile with new settings].
And you'll potentially still have problems with things that are implementation dependent (the problem with "same version, different build" I mentioned above is that someone who wrote STL implementation decided to change a constructor parameter from "unsigned int" to "size_t" at some point, which [could change or] changes the size of the data passed to the constructor -> not behaving the same when you call the function [but the shared library loader detects it and refuses to even load the executable/shared library combination]
[As Lightness Races in Orbit says, the above applies to the "Standard Template Library", which is things like std::vector
, std::map
, std::random
and many other things, but it does not include ALL of the runtime functionality that is required to write any non-trivial C++ program]

- 126,704
- 14
- 140
- 227
STL is primarily template-based code
The "STL" as the term is commonly used (which in itself is inaccurate) relates only to a very small subset of the C++ standard library, and plenty of the C++ standard library is not templates. And that still doesn't take into consideration any of the C++ runtime that your implementation has to link into your project.
So, assuming you mean either the C++ standard library or (more likely) the whole Visual Studio runtime … no, you can't inline it all.
You should probably rebuild the third-party library against your own toolchain.

- 1
- 1

- 378,754
- 76
- 643
- 1,055