Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange MFC / VC++ Linker Error (std::list<CRect> already defined)
    text
    copied!<p>I've got a really odd error message that only occurs when I add the following line to my project:</p> <pre><code>std::list&lt;CRect&gt; myVar; </code></pre> <p>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.</p> <p>Here is the error message:</p> <blockquote> <p>Error 1 error LNK2005: "public: __thiscall std::list</p> <blockquote> <p>::list >(void)" (??0?$list@VCRect@@V?$allocator@VCRect@@@std@@@std@@QAE@XZ) already defined in SomeLowLevelLibrary.lib</p> </blockquote> </blockquote> <p>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.</p> <p>I can get the linker error to go away if I change the line of code to:</p> <pre><code>std::list&lt;CRect*&gt; myVar; </code></pre> <p>But I don't want to hack it for the sake of it.</p> <p>Also, it doesn't matter if I create the variable on the stack or the heap, I still get the same error.</p> <p>Does anyone have any ideas whatsoever about this? I'm using Microsoft Visual Studio 2008 SP1 on Vista Enterprise.</p> <p><strong>Edit:</strong> The linker error above is for the std::list&lt;> constructor, I also get an error for the destructor, _Nextnode and clear functions.</p> <p><strong>Edit:</strong> 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.</p> <p><strong>Edit:</strong> The low level library doesn't have any classes that inherit from CRect, but it does make use of STL.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload