首页 > 其他分享 >使用vcpkg编译的glog报错:error C1189: #error: <glog/logging.h> was not included correctly.

使用vcpkg编译的glog报错:error C1189: #error: <glog/logging.h> was not included correctly.

时间:2024-06-10 19:31:59浏览次数:13  
标签:USE include logging GLOG EXPORT error 报错 glog

error C1189: #error: <glog/logging.h> was not included correctly.

使用vcpkg编译的glog,包含logging.h后编译下面的代码:

#include<glog/logging.h>
#include<iostream>

int main()
{
    printf("Test\n");
    return 0;
}

报错:error C1189: #error: <glog/logging.h> was not included correctly.

这是由于,自0.7.0版本起,包含logging.h前需要定义宏GLOG_USE_GLOG_EXPORTlogging.h中代码如下所示:

在这里插入图片描述
包含GLOG_USE_GLOG_EXPORT宏之后,logging.h中关于GLOG_EXPORTGLOG_NO_EXPORT的宏定义就都会生效。因此就不会产生上述错误信息。

添加GLOG_USE_GLOG_EXPORT定义后的代码如下:

#define GLOG_USE_GLOG_EXPORT
#include<glog/logging.h>
#include<iostream>

int main()
{
    printf("Test\n");
    return 0;
}

标签:USE,include,logging,GLOG,EXPORT,error,报错,glog
From: https://blog.csdn.net/qq_42679415/article/details/139579438

相关文章