You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Tomas Andersen <to...@morecom.no> on 2007/02/13 11:02:26 UTC

Is there a way to retrieve the last logged message from log4cxx?

Hi.
 
I am currently replacing an old logging API with log4cxx.
This old API had a method called Log::getLastError().
 
When doing code like this:
 
try
{
    a.method1();  // May throw exception that logs using Log API
    b.method2();  // May throw exception that logs using Log API
}
catch( SpecifiedException )
{
 
}
catch(...)  // All other exceptions
{
    // No way to retrieve messages from exceptions
    someinstance.throwUserException(Log::getLastError());  // Display
the last logged error to the user
}
 
it will be easy to display the last logged message to the user (by
throwing userexceptoin) without having to keep the errormessage stored
somewhere.
 
 
The problem when using log4cxx as I see it is that I use one logger
instance per class. So before I write a logger extension class to
log4cxx
in my project I just wanted to know if there is a method for retrieving
the last logged message by log4cxx within an application?
 
Regards
Tomas Andersen
moreCom AS

Re: Is there a way to retrieve the last logged message from log4cxx?

Posted by Curt Arnold <ca...@apache.org>.
There is not something like that currently in log4cxx or log4j.  I  
think it would be a bad thing to make your application behavior  
dependent upon log4cxx.  For example, if this user configured the  
hierarchy threshold to OFF the exception would no longer available.

In your particular case, you could do a couple of things:

1. Capture the exception outside of log4cxx
2. Redefine the appropriate LOG4CXX_ macros so that they also capture  
the message to an external source.  If you are only interested in  
ERROR level messages, then you could have an include file that does  
something like:

#undef LOG4CXX_ERROR
#define LOG4CXX_ERROR(logger, msg) \
MyErrorCache::setLastError(msg); \
body of original LOG4CXX_ERROR

3. Write a custom appender that captures the logging event and attach  
it to root, then query the appender.  This would require that the  
logging request would get down to the root logger which would not  
happen if threshold was set to OFF or a logger had set "additivity"  
to false.

RE: cppunit linking error when compiling using argument -Dlib.type=shared

Posted by jorrit de vries <jo...@student.hu.nl>.
>> Hello,
>>
>> When building a clean build of all libraries (apr, apr-util,  
>> cppunit and log4cxx) using the following arguments '-Ddebug=true| 
>> false -Doptimize=speed -Dlib.type=shared' I get linking errors when  
>> building cppunit. When removing the last argument (which seems to  
>> be the default ?) no problem occurs.
>>
>> Could ther be a problem in the build.xml? I am not very acquainted  
>> with Ant (only created small build scripts once for a school  
>> project, but the complexity of the provided file is beyond my  
>> current capabilities).
>>
>> Best regards,
>> Jorrit
>
> It would be very helpful to know the compiler are operating system  
> that you are using to attempt the build and the errors that you are  
> receiving.  If you are failing to build cppunit, you have likely  
> successfully build log4cxx, just haven't tested it.  You could try  
> "ant build-examples" and the "ant run-example -Dexample.name=trivial"  
> to do a minimal sanity test of the build.

Sorry. I am compiling on Windows XP, using the msvc8 compiler and this is
the (incomplete, since I can't get all the errors from the cmd) error log.
The sanity test worked fine though.

Cheers,
Jorrit

       [cc] consoleappendertestcase.obj : error LNK2001: unresolved external sym
bol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(cla
ss CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAE
XPAVTestFactory@2@@Z)
       [cc] charsetencodertestcase.obj : error LNK2001: unresolved external symb
ol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(clas
s CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEX
PAVTestFactory@2@@Z)
       [cc] relativetimedateformattestcase.obj : error LNK2001: unresolved exter
nal symbol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFact
ory(class CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUn
it@@QAEXPAVTestFactory@2@@Z)
       [cc] hierarchytest.obj : error LNK2001: unresolved external symbol "publi
c: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class CppUnit
::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTestFa
ctory@2@@Z)
       [cc] l7dtestcase.obj : error LNK2001: unresolved external symbol "public:
 void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class CppUnit::
TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTestFact
ory@2@@Z)
       [cc] customleveltestcase.obj : error LNK2001: unresolved external symbol
"public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class C
ppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAV
TestFactory@2@@Z)
       [cc] filterbasedrollingtest.obj : error LNK2001: unresolved external symb
ol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(clas
s CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEX
PAVTestFactory@2@@Z)
       [cc] sockethubappendertestcase.obj : error LNK2001: unresolved external s
ymbol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(c
lass CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@Q
AEXPAVTestFactory@2@@Z)
       [cc] optionconvertertestcase.obj : error LNK2001: unresolved external sym
bol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(cla
ss CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAE
XPAVTestFactory@2@@Z)
       [cc] xmllayouttestcase.obj : error LNK2001: unresolved external symbol "p
ublic: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class Cpp
Unit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTe
stFactory@2@@Z)
       [cc] cyclicbuffertestcase.obj : error LNK2001: unresolved external symbol
 "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class
CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPA
VTestFactory@2@@Z)
       [cc] streamtestcase.obj : error LNK2001: unresolved external symbol "publ
ic: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class CppUni
t::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTestF
actory@2@@Z)
       [cc] nteventlogappendertestcase.obj : error LNK2001: unresolved external
symbol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(
class CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@
QAEXPAVTestFactory@2@@Z)
       [cc] iso8601dateformattestcase.obj : error LNK2001: unresolved external s
ymbol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(c
lass CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@Q
AEXPAVTestFactory@2@@Z)
       [cc] socketappendertestcase.obj : error LNK2001: unresolved external symb
ol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(clas
s CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEX
PAVTestFactory@2@@Z)
       [cc] timezonetestcase.obj : error LNK2001: unresolved external symbol "pu
blic: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class CppU
nit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTes
tFactory@2@@Z)
       [cc] obsoleterollingfileappendertest.obj : error LNK2019: unresolved exte
rnal symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(v
oid)" (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ) referenced in function "[th
unk]:public: virtual class log4cxx::helpers::Class const & __thiscall log4cxx::P
atternLayout::getClass`vtordisp{4294967292,0}' (void)const " (?getClass@PatternL
ayout@log4cxx@@$4PPPPPPPM@A@BEABVClass@helpers@2@XZ)
       [cc] cacheddateformattestcase.obj : error LNK2001: unresolved external sy
mbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (
?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] filenamepatterntestcase.obj : error LNK2001: unresolved external sym
bol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?
isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] telnetappendertestcase.obj : error LNK2001: unresolved external symb
ol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?i
sValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] obsoletedailyrollingfileappendertest.obj : error LNK2001: unresolved
 external symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isVa
lid(void)" (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] minimumtestcase.obj : error LNK2001: unresolved external symbol "pub
lic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@
TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] patternlayouttest.obj : error LNK2001: unresolved external symbol "p
ublic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVali
d@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] ndctestcase.obj : error LNK2001: unresolved external symbol "public:
 static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Test
FactoryRegistry@CppUnit@@SA_NXZ)
       [cc] levelrangefiltertestcase.obj : error LNK2001: unresolved external sy
mbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (
?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] inetaddresstestcase.obj : error LNK2001: unresolved external symbol
"public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVa
lid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] leveltestcase.obj : error LNK2001: unresolved external symbol "publi
c: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Te
stFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] manualrollingtest.obj : error LNK2001: unresolved external symbol "p
ublic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVali
d@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] transcodertestcase.obj : error LNK2001: unresolved external symbol "
public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVal
id@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] syslogappendertestcase.obj : error LNK2001: unresolved external symb
ol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?i
sValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] absolutetimedateformattestcase.obj : error LNK2001: unresolved exter
nal symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(vo
id)" (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] sizebasedrollingtest.obj : error LNK2001: unresolved external symbol
 "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isV
alid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] datetimedateformattestcase.obj : error LNK2001: unresolved external
symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)"
 (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] domtestcase.obj : error LNK2001: unresolved external symbol "public:
 static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Test
FactoryRegistry@CppUnit@@SA_NXZ)
       [cc] odbcappendertestcase.obj : error LNK2001: unresolved external symbol
 "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isV
alid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] charsetdecodertestcase.obj : error LNK2001: unresolved external symb
ol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?i
sValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] patternparsertestcase.obj : error LNK2001: unresolved external symbo
l "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?is
Valid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] propertiestestcase.obj : error LNK2001: unresolved external symbol "
public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVal
id@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] filetestcase.obj : error LNK2001: unresolved external symbol "public
: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Tes
tFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] fileappendertestcase.obj : error LNK2001: unresolved external symbol
 "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isV
alid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] levelmatchfiltertestcase.obj : error LNK2001: unresolved external sy
mbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (
?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] xmlsocketappendertestcase.obj : error LNK2001: unresolved external s
ymbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)"
(?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] stringtokenizertestcase.obj : error LNK2001: unresolved external sym
bol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?
isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] rollingfileappendertestcase.obj : error LNK2001: unresolved external
 symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)
" (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] hierarchythresholdtestcase.obj : error LNK2001: unresolved external
symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)"
 (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] xloggertestcase.obj : error LNK2001: unresolved external symbol "pub
lic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@
TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] stringhelpertestcase.obj : error LNK2001: unresolved external symbol
 "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isV
alid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] encodingtest.obj : error LNK2001: unresolved external symbol "public
: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Tes
tFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] timebasedrollingtest.obj : error LNK2001: unresolved external symbol
 "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isV
alid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] loggertestcase.obj : error LNK2001: unresolved external symbol "publ
ic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@T
estFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] consoleappendertestcase.obj : error LNK2001: unresolved external sym
bol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?
isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] charsetencodertestcase.obj : error LNK2001: unresolved external symb
ol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?i
sValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] relativetimedateformattestcase.obj : error LNK2001: unresolved exter
nal symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(vo
id)" (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] hierarchytest.obj : error LNK2001: unresolved external symbol "publi
c: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Te
stFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] l7dtestcase.obj : error LNK2001: unresolved external symbol "public:
 static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@Test
FactoryRegistry@CppUnit@@SA_NXZ)
       [cc] customleveltestcase.obj : error LNK2001: unresolved external symbol
"public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVa
lid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] filterbasedrollingtest.obj : error LNK2001: unresolved external symb
ol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?i
sValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] sockethubappendertestcase.obj : error LNK2001: unresolved external s
ymbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)"
(?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] optionconvertertestcase.obj : error LNK2001: unresolved external sym
bol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?
isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] xmllayouttestcase.obj : error LNK2001: unresolved external symbol "p
ublic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isVali
d@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] cyclicbuffertestcase.obj : error LNK2001: unresolved external symbol
 "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isV
alid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] streamtestcase.obj : error LNK2001: unresolved external symbol "publ
ic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@T
estFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] nteventlogappendertestcase.obj : error LNK2001: unresolved external
symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)"
 (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] iso8601dateformattestcase.obj : error LNK2001: unresolved external s
ymbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)"
(?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] socketappendertestcase.obj : error LNK2001: unresolved external symb
ol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?i
sValid@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] timezonetestcase.obj : error LNK2001: unresolved external symbol "pu
blic: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid
@TestFactoryRegistry@CppUnit@@SA_NXZ)
       [cc] binarycompare.obj : error LNK2019: unresolved external symbol "publi
c: static void __cdecl CppUnit::Asserter::fail(class CppUnit::Message const &,cl
ass CppUnit::SourceLine const &)" (?fail@Asserter@CppUnit@@SAXABVMessage@2@ABVSo
urceLine@2@@Z) referenced in function "public: static void __cdecl log4cxx::util
::BinaryCompare::compare(char const *,char const *)" (?compare@BinaryCompare@uti
l@log4cxx@@SAXPBD0@Z)
       [cc] main.obj : error LNK2019: unresolved external symbol "public: virtua
l __thiscall CppUnit::TextTestRunner::~TextTestRunner(void)" (??1TextTestRunner@
CppUnit@@UAE@XZ) referenced in function __catch$_main$0
       [cc] main.obj : error LNK2019: unresolved external symbol "public: bool _
_thiscall CppUnit::TextTestRunner::run(class std::basic_string<char,struct std::
char_traits<char>,class std::allocator<char> >,bool,bool,bool)" (?run@TextTestRu
nner@CppUnit@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@
@_N11@Z) referenced in function _main
       [cc] main.obj : error LNK2019: unresolved external symbol "public: virtua
l void __thiscall CppUnit::TestRunner::addTest(class CppUnit::Test *)" (?addTest
@TestRunner@CppUnit@@UAEXPAVTest@2@@Z) referenced in function _main
       [cc] main.obj : error LNK2019: unresolved external symbol "public: __this
call CppUnit::TextTestRunner::TextTestRunner(class CppUnit::Outputter *)" (??0Te
xtTestRunner@CppUnit@@QAE@PAVOutputter@1@@Z) referenced in function _main
       [cc] inetaddresstestcase.obj : error LNK2019: unresolved external symbol
"public: __thiscall CppUnit::TestCaseDecorator::TestCaseDecorator(class CppUnit:
:TestCase *)" (??0TestCaseDecorator@CppUnit@@QAE@PAVTestCase@1@@Z) referenced in
 function "public: __thiscall CppUnit::ExceptionTestCaseDecorator<class log4cxx:
:helpers::UnknownHostException>::ExceptionTestCaseDecorator<class log4cxx::helpe
rs::UnknownHostException>(class CppUnit::TestCase *)" (??0?$ExceptionTestCaseDec
orator@VUnknownHostException@helpers@log4cxx@@@CppUnit@@QAE@PAVTestCase@1@@Z)
       [cc] inetaddresstestcase.obj : error LNK2001: unresolved external symbol
"public: virtual class std::basic_string<char,struct std::char_traits<char>,clas
s std::allocator<char> > __thiscall CppUnit::TestCaseDecorator::getName(void)con
st " (?getName@TestCaseDecorator@CppUnit@@UBE?AV?$basic_string@DU?$char_traits@D
@std@@V?$allocator@D@2@@std@@XZ)
       [cc] inetaddresstestcase.obj : error LNK2001: unresolved external symbol
"public: virtual void __thiscall CppUnit::TestCaseDecorator::setUp(void)" (?setU
p@TestCaseDecorator@CppUnit@@UAEXXZ)
       [cc] inetaddresstestcase.obj : error LNK2001: unresolved external symbol
"public: virtual void __thiscall CppUnit::TestCaseDecorator::tearDown(void)" (?t
earDown@TestCaseDecorator@CppUnit@@UAEXXZ)
       [cc] inetaddresstestcase.obj : error LNK2019: unresolved external symbol
"public: __thiscall CppUnit::Exception::Exception(class CppUnit::Message const &
,class CppUnit::SourceLine const &)" (??0Exception@CppUnit@@QAE@ABVMessage@1@ABV
SourceLine@1@@Z) referenced in function __catch$?runTest@?$ExceptionTestCaseDeco
rator@VUnknownHostException@helpers@log4cxx@@@CppUnit@@UAEXXZ$0
       [cc] inetaddresstestcase.obj : error LNK2019: unresolved external symbol
"public: static class std::basic_string<char,struct std::char_traits<char>,class
 std::allocator<char> > __cdecl CppUnit::TypeInfoHelper::getClassName(class type
_info const &)" (?getClassName@TypeInfoHelper@CppUnit@@SA?AV?$basic_string@DU?$c
har_traits@D@std@@V?$allocator@D@2@@std@@ABVtype_info@@@Z) referenced in functio
n __catch$?runTest@?$ExceptionTestCaseDecorator@VUnknownHostException@helpers@lo
g4cxx@@@CppUnit@@UAEXXZ$0
       [cc] inetaddresstestcase.obj : error LNK2019: unresolved external symbol
"public: __thiscall CppUnit::SourceLine::SourceLine(void)" (??0SourceLine@CppUni
t@@QAE@XZ) referenced in function __catch$?runTest@?$ExceptionTestCaseDecorator@
VUnknownHostException@helpers@log4cxx@@@CppUnit@@UAEXXZ$0
       [cc] inetaddresstestcase.obj : error LNK2019: unresolved external symbol
"public: virtual void __thiscall CppUnit::TestCaseDecorator::runTest(void)" (?ru
nTest@TestCaseDecorator@CppUnit@@UAEXXZ) referenced in function "public: virtual
 void __thiscall CppUnit::ExceptionTestCaseDecorator<class log4cxx::helpers::Unk
nownHostException>::runTest(void)" (?runTest@?$ExceptionTestCaseDecorator@VUnkno
wnHostException@helpers@log4cxx@@@CppUnit@@UAEXXZ)
       [cc] inetaddresstestcase.obj : error LNK2001: unresolved external symbol
"public: virtual __thiscall CppUnit::Exception::~Exception(void)" (??1Exception@
CppUnit@@UAE@XZ)
       [cc] inetaddresstestcase.obj : error LNK2001: unresolved external symbol
"public: __thiscall CppUnit::Exception::Exception(class CppUnit::Exception const
 &)" (??0Exception@CppUnit@@QAE@ABV01@@Z)
       [cc] inetaddresstestcase.obj : error LNK2019: unresolved external symbol
"public: virtual __thiscall CppUnit::TestCaseDecorator::~TestCaseDecorator(void)
" (??1TestCaseDecorator@CppUnit@@UAE@XZ) referenced in function "public: virtual
 __thiscall CppUnit::ExceptionTestCaseDecorator<class log4cxx::helpers::UnknownH
ostException>::~ExceptionTestCaseDecorator<class log4cxx::helpers::UnknownHostEx
ception>(void)" (??1?$ExceptionTestCaseDecorator@VUnknownHostException@helpers@l
og4cxx@@@CppUnit@@UAE@XZ)
       [cc] log4cxx-test.exe : fatal error LNK1120: 47 unresolved externals


Re: cppunit linking error when compiling using argument -Dlib.type=shared

Posted by Curt Arnold <ca...@apache.org>.
On Feb 13, 2007, at 9:04 AM, jorrit de vries wrote:

> Hello,
>
> When building a clean build of all libraries (apr, apr-util,  
> cppunit and log4cxx) using the following arguments '-Ddebug=true| 
> false -Doptimize=speed -Dlib.type=shared' I get linking errors when  
> building cppunit. When removing the last argument (which seems to  
> be the default ?) no problem occurs.
>
> Could ther be a problem in the build.xml? I am not very acquainted  
> with Ant (only created small build scripts once for a school  
> project, but the complexity of the provided file is beyond my  
> current capabilities).
>
> Best regards,
> Jorrit

It would be very helpful to know the compiler are operating system  
that you are using to attempt the build and the errors that you are  
receiving.  If you are failing to build cppunit, you have likely  
successfully build log4cxx, just haven't tested it.  You could try  
"ant build-examples" and the "ant run-example -Dexample.name=trivial"  
to do a minimal sanity test of the build.

cppunit linking error when compiling using argument -Dlib.type=shared

Posted by jorrit de vries <jo...@student.hu.nl>.
Hello,

When building a clean build of all libraries (apr, apr-util, cppunit and log4cxx) using the following arguments '-Ddebug=true|false -Doptimize=speed -Dlib.type=shared' I get linking errors when building cppunit. When removing the last argument (which seems to be the default ?) no problem occurs.

Could ther be a problem in the build.xml? I am not very acquainted with Ant (only created small build scripts once for a school project, but the complexity of the provided file is beyond my current capabilities).

Best regards,
Jorrit