Sorry-in the last message, it should read "and yet I still get the
warnings listed below," rather than "errors".

 

Elaine

 

________________________________

From: Hale, Elaine [mailto:elaine_h...@nrel.gov] 
Sent: Friday, December 19, 2008 5:56 PM
To: Log4CXX User
Subject: RE: MS Visual Studio 2008 LNK2005 and LNK4006 errors and
warnings that seem to be associated with log4cxx

 

I just verified that for my small library example, the runtime libraries
and character sets specified in the project properties match the log4cxx
projects' (apr, apr-util, log4cxx and xml), and yet I still get the
errors listed below.

 

Cheers,

Elaine

 

________________________________

From: Fabian Jacquet [mailto:fabian.jacq...@gmail.com] 
Sent: Monday, December 15, 2008 4:27 AM
To: Log4CXX User
Subject: Re: MS Visual Studio 2008 LNK2005 and LNK4006 errors and
warnings that seem to be associated with log4cxx

 

Hi,

My problem was log4cxx was compiled with /MT option and my project with
/MD and one was compiled with unicode character set the other with no
unicode.

On Mon, Dec 15, 2008 at 09:41, Fabian Jacquet <fabian.jacq...@gmail.com>
wrote:

Hello,

I have the same problem.
I tested log4cxx compiled in static mode with a little command line
program and all was ok.
So now I try to use log4cxx in my big program using GUI and MFC and I
have the same link error.

I'm searching about a solution. If you find before me please contact me.
Thank you.

 

On Wed, Dec 10, 2008 at 03:51, Hale, Elaine <elaine_h...@nrel.gov>
wrote:

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> > *)"
(?dest...@?$allocator@v?$basic_str...@du?$char_traits@d...@std@@V?$allocato
r...@d@2@@std@@@std@@qaexpav?$basic_str...@du?$char_traits@d...@std@@V?$alloca
t...@d@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)"
(??1?$_container_base_aux_alloc_em...@v?$allocator@v?$basic_str...@du?$c
har_tra...@d@std@@v?$alloca...@d@2@@std@@@std@@@std@@i...@xz) 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)"
(?dealloc...@?$allocator@v?$basic_str...@du?$char_traits@d...@std@@V?$alloc
a...@d@2@@std@@@std@@qaexpav?$basic_str...@du?$char_traits@d...@std@@V?$all
oca...@d@2@@2...@i@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)"
(??1?$_container_base_aux_alloc_em...@v?$allocator@v?$basic_str...@du?$c
har_tra...@d@std@@v?$alloca...@d@2@@std@@@std@@@std@@i...@xz) 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)"
(?dealloc...@?$allocator@v?$basic_str...@du?$char_traits@d...@std@@V?$alloc
a...@d@2@@std@@@std@@qaexpav?$basic_str...@du?$char_traits@d...@std@@V?$all
oca...@d@2@@2...@i@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> > *)"
(?dest...@?$allocator@v?$basic_str...@du?$char_traits@d...@std@@V?$allocato
r...@d@2@@std@@@std@@qaexpav?$basic_str...@du?$char_traits@d...@std@@V?$alloca
t...@d@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

 

elaine_h...@nrel.gov

303-384-7812

MS 4111

 

 

Reply via email to