glog vs2015 编译问题

转自: 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 以供调试时使用。









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值