My TestDLL.cpp code looks like this:
#ifdef DLL_EXPORTS
__declspec(dllexport) void test();
#else
__declspec(dllimport) void test();
#endif
#include "stdafx.h"
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
void test()
{
GdiplusStartupInput gdiplusStartupInput;
}
Now when im trying to compile the dll there are 100+ errors from header files of GDI+. However the GDI+ works(compiles) fine on my console application (exe). Isn't GDI+ compatible with D开发者_StackOverflow社区LL's or what? And the gdiplus.lib is linked incase someone asks it...
I had the same problem. The following line fixed it.
#pragma comment (lib,"Gdiplus.lib")
I hope this helps.
Put this inside your precompiled header
#include <stdio.h>
#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
The errors are likely due to invalid macros defined, see this MS article
You probably need to add gdi+ to the libraries your project is linking against. Check the project properties.
Lines like using namespace gdiplus;
are dangerous in that they pull everything from that namespace into the current namespace. This can lead to problems linking when you're building a DLL.
It's also possible that one of those headers is using the same DLL_EXPORTS
But a sampling of the first few error messages would make it a lot easier for people to help you.
I also came here after getting numerous errors when compiling my DLL using GDI+. However, none of the answers applied to my case. Reason for my getting errors in my DLL was defining the macro WIN32_LEAN_AND_MEAN. So, make sure this macro does not get defined for you when you get such errors for GDI+ APIs/types. To resolve, remove any definitions of this macro (if you can find them) or undefine them at the top of your source file before you include any of the platform header files like so:
#undef WIN32_LEAN_AND_MEAN
精彩评论