I ensure that i compiled log4cplus project as Dynamic Lib with Unicode charset(Debug_Unicode) and my own test project also had been set to Unicode charset. Both of them compiled under debug model. I have read many similar questions but still cannot resolve this problem... Following is my test code :
#include "Include/log4cplus/loggingmacros.h"
#include "Include/log4cplus/configurator.h"
#include "Include/log4cplus/helpers/loglog.h"
#include "Include/log4cplus/helpers/stringhelper.h"
#include "Include/log4cplus/helpers/fileinfo.h"
#include "Include/log4cplus/loggingmacros.h"
#include "Include/log4cplus/initializer.h"
#pragma comment(lib, "log4cplusUD.lib")
using namespace std;
using namespace log4cplus;
using namespace log4cplus::helpers;
int main(int argc, wchar_t* argv[])
{
cout << LOG4CPLUS_TEXT("Entering main()...") << endl;
log4cplus::Initializer initializer;
LogLog::getLogLog()->setInternalDebugging(true);
Logger root = Logger::getRoot();
try {
PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("E:\\log4cplus.properties"));
Logger fileCat = Logger::getInstance(LOG4CPLUS_TEXT("filelogger"));
LOG4CPLUS_WARN(root, LOG4CPLUS_TEXT("Testing...."));
LOG4CPLUS_WARN(root, LOG4CPLUS_TEXT("Writing messages to log...."));
for (int i = 0; i<10000; ++i)
LOG4CPLUS_WARN(fileCat, LOG4CPLUS_TEXT("This is a WARNING...")
<< i);
#define TEST_TEXT LOG4CPLUS_TEXT ("this is a test with DOS EOL-->")
tistringstream propsStream(
LOG4CPLUS_TEXT("text=") TEST_TEXT LOG4CPLUS_TEXT("\r\n"));
Properties props(propsStream);
LOG4CPLUS_ASSERT(root,
props.getProperty(LOG4CPLUS_TEXT("text")) == TEST_TEXT);
}
catch (...) {
tcout << LOG4CPLUS_TEXT("Exception...") << endl;
LOG4CPLUS_FATAL(root, LOG4CPLUS_TEXT("Exception occured..."));
}
http: cout << LOG4CPLUS_TEXT("Exiting main()...") << endl;
return 0;
}
I'm just copy this code from "propertyconfig_test" in log4cplus, the lib and dll file is also compiled with "Debug_Unicode",when I compiled my own test project then a link error occurs:
error LNK2001: unresolved external symbol "class std::basic_ostream<wchar_t,struct std::char_traits<wchar_t=""> > & log4cplus::tcout"
(?tcout@log4cplus@@3AAV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@A)
E:\TestCode\1026(thttpd)\thttpd\thttpd\thttpd.obj thttpd
Just now,I found that if I comment these sentences which include the "tcout" function,then everything is OK,This example about propertyconfig_test works well,why?
What I have tried:
Try each compiled model and charset,read lots of similar questions