Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#include <gdiplus.h> causes error

Tags:

c++

visual-c++

When I include gdiplus.h in a program that compiles well the first(there are many) error I get is:

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

Part of GdiplusImaging.h:

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

Why it is so? Where is this IUnknown class? And why it's not in GdiplusImaging.h?

My system is Windows7 x64. VisualStudio 2010.

Including part:

#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "gdiplus.lib")
like image 899
Sergey Avatar asked Sep 05 '11 08:09

Sergey


2 Answers

You should try to add windows.h and Unknwn.h header before gdiplus.h

#include <Unknwn.h>
#include <windows.h>
#include <gdiplus.h>
like image 84
Cedekasme Avatar answered Sep 28 '22 10:09

Cedekasme


These are the standard includes for using GDI+:

#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
like image 26
SChepurin Avatar answered Sep 28 '22 10:09

SChepurin