Hello,
I was writing and running some tests for a project that uses log4cxx and some other third party libraries, and received the following linking errors upon adding the line ::std::deque<::std::string> textSnippets; to my testing header file (the errors go away if I comment it out): 4>Linking... 4>LINK : C:\projects\pathfinders\cpp\utilities\projects\lib\Debug\ApplicationUtil ities_Tests.exe not found or not built by the last incremental link; performing full link 4>ApplicationUtilities.lib(log4cxx.dll) : error LNK2005: "public: void __thiscall std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::destroy(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" ([EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$allocato [EMAIL PROTECTED]@2@@std@@@std@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$alloca [EMAIL PROTECTED]@2@@2@@Z) already defined in ApplicationUtilities_Tests.obj 4>ApplicationUtilities.lib(log4cxx.dll) : error LNK2005: "protected: __thiscall std::_Container_base_aux_alloc_empty<class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::~_Container_base_aux_alloc_empty<class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >(void)" ([EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@std@@[EMAIL PROTECTED]@2@@std@@@std@@@std@@[EMAIL PROTECTED]) already defined in ApplicationUtilities_Tests.obj 4>ApplicationUtilities.lib(log4cxx.dll) : error LNK2005: "public: void __thiscall std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::deallocate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,unsigned int)" ([EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$alloc [EMAIL PROTECTED]@2@@std@@@std@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$all [EMAIL PROTECTED]@2@@[EMAIL PROTECTED]@Z) already defined in ApplicationUtilities_Tests.obj 4>C:\projects\pathfinders\cpp\utilities\projects\lib\Debug\ApplicationUt ilities_Tests.exe : fatal error LNK1169: one or more multiply defined symbols found General online help concerning LNK2005 errors associated with the standard template library suggests checking that all of the runtime libraries (under Properties->C++->Code Generation) in all dependencies are identical. So I did that, and they all seem to be set identically to Multi-threaded Debug DLL (/MDd) (in the debug versions). That includes my log4cxx and other third-party builds. I therefore tried to isolate the problem by creating a small project that reproduces the errors. I didn't quite succeed, but I did get the following warnings, which seem very similar to the LNK2005 errors above, from a simple library that uses log4cxx.lib and deque<string>: 1>------ Rebuild All started: Project: StdLibLinkingBug, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'StdLibLinkingBug', configuration 'Debug|Win32' 1>Compiling... 1>StdLibLinkingBug.cpp 1>Creating library... 1>StdLibLinkingBug.obj : warning LNK4006: "protected: __thiscall std::_Container_base_aux_alloc_empty<class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::~_Container_base_aux_alloc_empty<class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >(void)" ([EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@std@@[EMAIL PROTECTED]@2@@std@@@std@@@std@@[EMAIL PROTECTED]) already defined in log4cxx.lib(log4cxx.dll); second definition ignored 1>StdLibLinkingBug.obj : warning LNK4006: "public: void __thiscall std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::deallocate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,unsigned int)" ([EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$alloc [EMAIL PROTECTED]@2@@std@@@std@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$all [EMAIL PROTECTED]@2@@[EMAIL PROTECTED]@Z) already defined in log4cxx.lib(log4cxx.dll); second definition ignored 1>StdLibLinkingBug.obj : warning LNK4006: "public: void __thiscall std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::destroy(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" ([EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$allocato [EMAIL PROTECTED]@2@@std@@@std@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?$alloca [EMAIL PROTECTED]@2@@2@@Z) already defined in log4cxx.lib(log4cxx.dll); second definition ignored 1>Build log was saved at "file://c:\projects\pathfinders\cpp\utilities\projects\debugging\StdLibL inkingBug\Debug\BuildLog.htm" 1>StdLibLinkingBug - 0 error(s), 3 warning(s) ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== Since writing similar small programs with the other third party libraries I'm using did not produce anything similar to the LNK2005 errors, I am guessing that log4cxx is the culprit. Other (possibly) useful information: - the warnings and errors do not go away if I replace deque<string> with vector<string>, but they do go away if I replace deque<string> with deque<int> - the original problem cropped up in a series of dependent static library projects that were finally linked into a .exe. Basically the situation is something like (where x -> y means y uses or is dependent on x): log4cxx -> lib1 (log4cxx wrapper for outputing log messages) -> lib2 -> lib3 (which declares a deque<string> and configures log4cxx loggers); lib2 and lib3 -> exe (which gives linking errors when it declares a deque<string>) - the code for the small library that produced the LNK4006 warnings follows. The .vsproj file lists log4cxx as a dependency. The warnings go away if this listing is removed. // StdLibLinkingBug.h #include <deque> #include <string> #ifndef STDLIBLINKINGBUG_H #define STDLIBLINKINGBUG_H void functionThatLogs(std::deque<std::string>); #endif // STDLIBLINKINGBUG_H // StdLibLinkingBug.cpp #include "StdLibLinkingBug.h" #include <log4cxx/logger.h> using namespace std; using namespace log4cxx; LoggerPtr logger(Logger::getLogger("StdLibLinkingBug")); void functionThatLogs(std::deque<std::string> aStringDeque) { LOG4CXX_WARN(logger,"A silly message " << aStringDeque.at(0)) } Any help anyone can provide would be greatly appreciated. This bug has me stumped! Thanks, Elaine Elaine T. Hale, Ph.D. Buildings and Thermal Systems Center National Renewable Energy Laboratory [EMAIL PROTECTED] 303-384-7812 MS 4111