如何编译使用Windows.H和Google Glog(Glog/Loggging.h)的C 程序
How to compile a c++ program that uses both windows.h and google glog (glog/logging.h)?
我有两个库A和B。库B是我自己的库,我需要其中的" Windows.h"。此外,对于某些功能,我需要使用第三方库A。A使用Google Logging库,这是问题:
第一个错误是:
Severity Code Description Project File Line Error C1189 #error: ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h
我在" a.h"之前定义了glog_no_abbreviated_severities,但是在出现了奇怪的链接错误之后。我已经测试了这里建议的所有解决方案,但它们都没有起作用。
在使用" Windows.h"的项目中使用GLOG的其他方法?
编辑:
链接器错误是:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(char)" (__imp_?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<char,struct std::char_traits<char>,char>(class std::basic_ostream<char,struct std::char_traits<char> > &,struct std::_Fillobj<char> const &)" (??$?6DU?$char_traits@D@std@@D@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABU?$_Fillobj@D@0@@Z)
error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::ios_base & (__cdecl*)(class std::ios_base &))" (__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z) referenced in function _getHtsLables
error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(double)" (__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z) referenced in function "public: virtual void __thiscall AD3::FactorDense::Print(class std::basic_ostream<char,struct std::char_traits<char> > &)" (?Print@FactorDense@AD3@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
fatal error LNK1120: 3 unresolved externals
-
在包括
之前定义logging.h
GLOG_NO_ABBREVIATED_SEVERITIES
#define GLOG_NO_ABBREVIATED_SEVERITIES #include <windows.h> #include <glog/logging.h>
-
在Visual Studio中的预处理器定义中添加
GLOG_NO_ABBREVIATED_SEVERITIES
,即Project > Properties > C/C++ > Preprocessor
。
我在添加glog_no_abbreviated_severities后重新编译A,但没有任何改变。但是,通过重新排序" A.H"answers" Windows.H"来解决问题。当我在" windows.h"之前包括" a.h"时,没有出现错误!!!我不明白链接器错误的真正原因是什么! - Payman
相关文章:
- 如何将 glog 与 bazel 一起使用?
- 安装Glog链接错误
- Tensorflow C++ API 和 Caffe 兼容性问题与 Glog 相关
- 尝试在Windows结果上使用GLOG未定义的参考
- GLOG多线程日志
- 如何在Linux上使用Minw编译glog来生成glog dll
- 在Windows上安装GLog
- Glog库(Google Log)在StackTrace中打印出`(未知)
- 如何编译使用Windows.H和Google Glog(Glog/Loggging.h)的C 程序
- 在Google UnitTest中检测glog输出
- 与 glog 库链接
- 如何通过谷歌glog打印完全双倍精度
- 将谷歌日志(glog)重定向到文件
- GLOG 仅保存到文件中,第一条消息
- 从 GLOG 执行系统日志时如何更改标签'UNKNOWN'?
- VLOG不适用于谷歌日志记录库(glog)
- glog on visual studio 2015