I've got a really odd error message that only occurs when I add the following line to my project:
std::list<CRect> myVar;
It's worth noting that it doesn't have to be a std::list, it can be std::vector or any other STL container I assume.
Here is the error message:
Error 1 error LNK2005: "public: __thiscall std::list
::list >(void)" (??0?$list@VCRect@@V?$allocator@VCRect@@@std@@@std@@QAE@XZ) already defined in SomeLowLevelLibrary.lib
The low level library that's referenced in the error message has no idea about the project I am building, it only has core low level functionality and doesn't deal with high level MFC GUIs.
I can get the linker error to go away if I change the line of code to:
std::list<CRect*> myVar;
But I don't want to hack it for the sake of it.
Also, it doesn't matter if I create the variable on the stack or the heap, I still get the same error.
Does anyone have any ideas whatsoever about this? I'm using Microsoft Visual Studio 2008 SP1 on Vista Enterprise.
Edit: The linker error above is for the std::list<> constructor, I also get an error for the destructor, _Nextnode and clear functions.
Edit: In other files in the project, std::vector won't link, in other files it might be std::list. I can't work out why some containers work, and some don't. MFC linkage is static across both libraries. In the low level library we have 1 class that inherits from std::list.
Edit: The low level library doesn't have any classes that inherit from CRect, but it does make use of STL.