QQ技术交流群:129518033
Glog地址:https://github.com/google/glog
平台:windows
开发工具:VS2010
下载完成之后,用VS2010进行编译,默认是vs2008让其自动转换,如图所示。
编译,在Debug下生成libglog.dll、 libglog.lib、libglog_static.lib
将头文件和lib库拷贝到自己的工程下,头文件使用 src\windows\glog
这一步很重要
1、配置include和lib,让vs找到头文件和库文件
2、链接器输入lib静态文件
3、预处理器设置
这个参数不设置会报如下错误:
1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> SessionMgr.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> SessionFactory.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> RealTimeStreamSession.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> main.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> GNumGenerator.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> DevicControlSession.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 1> CatalogSesssion.cpp 1>d:\workspace\video\videomanage\devicemgr\lib\glog\glog\log_severity.h(55): fatal error C1189: #error : ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
#include "stdafx.h" #include <glog/logging.h> int _tmain(int argc, _TCHAR* argv[]) { google::InitGoogleLogging((const char *)argv[0]); //参数为自己的可执行文件名 google::SetLogDestination(google::GLOG_INFO,"./Log"); LOG(INFO) << "Glog test INFO"; LOG(INFO) << "Glog test INFO 2"; return 0; }
这个时候进行生成的时候会报一个错误,提示没有inttypes.h文件。
错误 1 error C1083: 无法打开包括文件:“inttypes.h”: No such file or directory d:\documents\visual studio 2010\projects\glog\glog\glog\logging.h 82 1 glog
这是因为VS2010对C99支持的不好导致的。
解决办法:
参考文献:http://www.cnblogs.com/zyl910/archive/2012/08/08/c99int.html
从网上下载一个“inttypes.h”,放到VS2010的VC目录下的include文件夹中
http://download.csdn.net/detail/itas109/9499680
如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033