Linking with glog library

4.5k Views Asked by At

I'm trying to use the glog logging library (LINK). In VS2012 (I'm on Windows 8 Professional 64-bit (Japanese)), I create an empty solution with a single main.cpp file like the one in the documentation (LINK). Also I import the glog project inside the solution (either the dll one or the static library one) and set the project dependency. To avoid some errors I have to comment out line 97 from port.h:

/* In windows-land, hash<> is called hash_compare<> (from xhash.h) */
#define hash  hash_compare

While glog compiles, the main application gives me unresolved external symbol erros (with both dll and static version).

1>main.obj : error LNK2019: 未解決の外部シンボル "void __cdecl google::InitGoogleLogging(char const *)" (?InitGoogleLogging@google@@YAXPBD@Z) が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル "public: __thiscall google::LogMessage::LogMessage(char const *,int)" (??0LogMessage@google@@QAE@PBDH@Z) が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル "public: __thiscall google::LogMessage::~LogMessage(void)" (??1LogMessage@google@@QAE@XZ) が関数 _main で参照されました。

I'm compiling as Win32. If I check the debug folder it actually contains the dll+lib or static lib file. I also tried linking to the library manually without using the visual studio dependency system, but it's the same.

1

There are 1 best solutions below

2
On BEST ANSWER

I've built glog for MSVS2012 from trunk (little patch mentioned in header already presented here, as i know), so it works for me. Looks like your dependency description of glog library is missing.

Can you add windows-specific

#pragma comment(lib, "path_to_glog_from_project_dir.lib") 

to one of your project files, for example, directly into main.cpp and test it.