Link errors with STL
Tim Hagemann -- 100063.323@compuserve.com
Wednesday, February 14, 1996
Hi Folks !
I tried to use STL with MFC. I created a header, which includes all other stl
headers
and included this header in "stdafx.h" to use the advantages of the precompiled
headers.
When linking, the following errors occur:
teststlDlg.obj : error LNK2005: "void __cdecl std::swap(class
std::bit_vector::reference,class
std::bit_vector::reference)"(?swap@std@@YAXVreference@bit_vector@1@0@Z) already
defined in teststl.obj
teststlDlg.obj : error LNK2005: "protected: void __thiscall
std::bit_vector::insert_aux(class
std::bit_vector::iterator,int)"(?insert_aux@bit_vector@std@@IAEXViterator@12@H@Z)
already defined in teststl.obj
[snip snip]
I also tried including my "stl-header" in the source code direcly, but the same
happens.
Any help ?
Tim Hagemann
gyoung@CDA.COM
Friday, February 16, 1996
[Mini-digest: 2 responses]
Did you read the readme that came with STL on the MSVC CD? Also be
sure to check MFC FAQ 4.0 for some #include requirements not covered
in the readme.
-- Greg Young
gyoung@cda.com
-----From: "Edward Blakes, Jr."
bit_vector is a specialization of vector provided for space
efficiency. Unfortunately, the definitions (ie. function bodies) are source
inlined (not compiled inline) in the header (which one, I forget). Pull the
non-inline (compile type) bit_vector function member definitions out into a
new source file (.cpp), make it a library if you wish, and recompile
everything that included the header with the bit_vector in it.
Some compilers throw out the duplicate definitions and don't say anything.
VC4 does not.
--
Edward Blakes, Jr. email: eblakes@ffg.com
ForeFront Group voice: (713) 961-1101
http://www.ffg.com fax: (713) 961-1149
| Вернуться в корень Архива
|