Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4cplus link errors when used in VS2012

I've download and compiled log4cplus in VS2012. Compilation was fine (both debug and release) I've tried to use it my code but I get 3 link errors, nothing I tried didn't remove them. I'm using the same includes from the log4cplus project, and the libs I've compiled (tried all 3... debug release and the log4cplusS.lib

I still get these:

error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostringstream,class std::allocator > & __cdecl log4cplus::detail::get_macro_body_oss(void)" (_imp?get_macro_body_oss@detail@log4cplus@@YAAAV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@XZ) referenced in function "int __cdecl Prepare(class std::basic_string,class std::allocator > &,class std::basic_string,class std::allocator > &,class std::basic_string,class std::allocator > &,int *,int *,int *)" (?Prepare@@YAHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00PAH11@Z)

error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string,class std::allocator > const &)" (_imp?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "int __cdecl Prepare(class std::basic_string,class std::allocator > &,class std::basic_string,class std::allocator > &,class std::basic_string,class std::allocator > &,int *,int *,int *)" (?Prepare@@YAHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00PAH11@Z)

What is wrong?

My code is simple, in my dll cpp:

in the top of cpp I added

static Logger logger;

in one of the function I've added:

logger = Logger::getInstance(LOG4CPLUS_TEXT("MyDLL"));
LOG4CPLUS_INFO(logger, LOG4CPLUS_TEXT("Prepare Starts"));
like image 770
Dani Avatar asked Sep 16 '13 13:09

Dani


1 Answers

It is likely that you have compiled log4cplus using the Release configuration. You will need to use Release_Unicode (similarly for Debug configuration).

like image 133
wilx Avatar answered Oct 08 '22 18:10

wilx