0

I'm trying to use log4cpp in my MSVC project. I downloaded log4cpp, and opened its msvc10\msvc10.sln file. I'm using Visual Studio 2012 (msvc11), so it prompted me to update log4cpp's projects. I did and everything seemed to go smoothly. Then I built the log4cppLIB project. It generated msvc10\log4cppLIB\Debug\log4cppD.lib. Seems so far so good.

Back in my own project, I added msvc10\log4cppLIB\Debug to my linker library directories and log4cppD.lib to my linker dependencies. When I try to build my project, I get this error:

error LNK2019: unresolved external symbol "public: static class log4cpp::Category & __cdecl log4cpp::Category::getInstance(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getInstance@Category@log4cpp@@SAAEAV12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 

Things I've tried:

  • Maybe my linker path or file name is wrong? Nope, because if I deliberately use a wrong path, then I get a different kind of error (fatal error LNK1104: cannot open file 'log4cpp.lib')

  • Maybe the memory model needs to match? My project is x64 and log4cpp defaults to win32. But nope. I changed log4cpp to x64 and rebuilt. But then re-building my project produces even more errors, of this variety (error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug').

Any thoughts?

Jeff M
  • 2,492
  • 3
  • 22
  • 38
  • 1
    You need to have the library compiled at the same bit depth and same runtime. In your first bullet you had mixed 32 and 64 bit in the second you are selecting a different runtime (/MDd versus /MTd) for the library and your application. – drescherjm Feb 06 '15 at 18:31

1 Answers1

0

Apparently I did indeed have to compile as x64 and I had to change the Runtime Libary from Multi-threaded Debug DLL (/MDd) to Multi-threaded Debug (/MTd). I'm not sure why it was set that way to begin with, but... meh. It's working now. :)

Jeff M
  • 2,492
  • 3
  • 22
  • 38