转自: http://www.guanshuwei.com/archives/174
(1)编译glog库:
glog在vs2015直接编译会有些问题。 总结来说有两个地方需要修改。
一:
对port.cc port.h中关于snprintf的定义和声明进行注释。
port.h 中注释掉 #define va_copy 这一行。
二:
在LogStream定义中加入如下两行
LogStream(const LogStream&) = delete;
LogStream& operator=(const LogStream&) = delete;
(2)编译项目:
静态链接 libglog_static 编译项目的时候报错:
(1)Error C1189#error: ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h.
See the document for detail.gameserverd:\mycode\code\glog\src\windows\glog\log_severity.h55
(2)Error LNK2019unresolved external symbol "__declspec(dllimport) public: __thiscall google::LogMessage::LogMessage(char const *,int)"
(__imp_??0LogMessage@google@@QAE@PBDH@Z) referenced in function "private: void __thiscall MainFrame::OnHello(class wxCommandEvent &)"
(?OnHello@MainFrame@@AAEXAAVwxCommandEvent@@@Z) gameserver D:\mycode\code\gameserver\main.obj1
glog如何采用静态链接的方式呢?答案是要看官方doc文档的说法:在自定义工程中添加“GOOGLE_GLOG_DLL_DECL=” 和 “GLOG_NO_ABBREVIATED_SEVERITIES” 这两个宏,第二个宏主要是为了避免与windows.h冲突(下面会讲到),第一个宏才是使用静态链接库时必须的!在编译时可以编译两个版本:Release 和 Debug 以供调试时使用。