Question

I'm trying to compile a project, but when I include a map object, it gives me a LNK2001 error. I've included the correct header file, but I don't know what the library is that I should be including.

I'm using Visual Studio 2008, and when I set "Ignore All Default Libraries" to "No" it will work, but having the properties set that way isn't an allowed option for the final outcome. I thought there would be some sort of all-STL library, but I have vectors and dequeues in my code, and they work fine. It's only when I add in a map object that the error shows up.

Was it helpful?

Solution 2

So, a friend had a similar problem, and the library I needed was msvcprt.lib .

OTHER TIPS

The correct include should look like that:

#include <map>

And the correct initialization of map should look something like that:

std::map<int, char> mymap;

That is probably an optimization in the STL implementation -- code that is not dependent on any template parameter is split off into a base class, so only a single copy is used across all instances, and this copy is kept in the C++ standard library, so you will not be able to avoid linking against this library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top