【问题标题】:#include <gdiplus.h> causes error#include <gdiplus.h> 导致错误
【发布时间】:2011-09-05 08:34:19
【问题描述】:

当我在一个编译良好的程序中包含gdiplus.h 时,我得到的第一个(有很多)错误是:

c:\program files (x86)\microsoft sdks\windows\v7.0a\include\GdiplusImaging.h(77): error C2504: 'IUnknown' : base class undefined

GdiplusImaging.h 的一部分:

IImageBytes : public IUnknown  <<< error!
{
public:
     ...

为什么会这样?这个 IUnknown 类在哪里?为什么它不在 GdiplusImaging.h 中?

我的系统是 Windows7 x64。视觉工作室 2010。

包括部分:

#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "gdiplus.lib")

【问题讨论】:

  • 在gdiplus.h 之前是否包含windows.h?
  • 无法复制。你的配置有问题。
  • 现在重装sdk,我觉得有问题
  • 如果重新安装 sdk 不能解决问题,请尝试将“显示包含”(在 C/C++ -> 高级下)设置为 Yes,然后重新编译。您将在输出窗口中看到包含的顺序。可以让事情更清楚。
  • 感谢您的提示,包括 Unknwn.h 在内的简单内容拯救了我的灵魂

标签: c++ visual-c++


【解决方案1】:

这些是使用 GDI+ 的标准:

#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")

【讨论】:

  • 我使用了这个确切的块,但仍然存在在 gdiplustype.h 文件(包含在 gdiplus.h 内部)中未定义的最小/最大宏的问题。以下线程帮助 -stackoverflow.com/questions/4913922/…
  • 如果您尝试将其构建为Visual Studio 2017 - Windows XP (v141_xp) 的平台工具集,这在 VS2017 下不起作用。这是more info。有人知道如何构建这些 GDI+ 库吗?
【解决方案2】:

您应该尝试在gdiplus.h 之前添加windows.h 和Unknwn.h 标头

#include <Unknwn.h>
#include <windows.h>
#include <gdiplus.h>

【讨论】:

  • 您是否尝试在调用gdiplus.h 之前强制添加Unknwn.h 标头?
  • 我想知道为什么不将它包含在 gdi 标头中?它有帮助!谢谢。将其添加到答案中。
猜你喜欢
  • 2020-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-13
  • 1970-01-01
相关资源
最近更新 更多