我正在尝试在Win32控制台应用程序(VS 2012)中从此页面http://msdn.microsoft.com/en-us/library/windows/desktop/ms534077(v=vs.85).aspx运行代码
并出现以下错误:
Error 3 error LNK2019: unresolved external symbol _GdiplusStartup@12 referenced in function _main c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 4 error LNK2019: unresolved external symbol _GdiplusShutdown@4 referenced in function _main c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 6 error LNK2019: unresolved external symbol _GdipLoadImageFromFileICM@8 referenced in function "public: __thiscall Gdiplus::Image::Image(wchar_t const *,int)" (??0Image@Gdiplus@@QAE@PB_WH@Z) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 5 error LNK2019: unresolved external symbol _GdipLoadImageFromFile@8 referenced in function "public: __thiscall Gdiplus::Image::Image(wchar_t const *,int)" (??0Image@Gdiplus@@QAE@PB_WH@Z) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 9 error LNK2019: unresolved external symbol _GdipGetImageWidth@8 referenced in function "public: unsigned int __thiscall Gdiplus::Image::GetWidth(void)" (?GetWidth@Image@Gdiplus@@QAEIXZ) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 10 error LNK2019: unresolved external symbol _GdipGetImageHeight@8 referenced in function "public: unsigned int __thiscall Gdiplus::Image::GetHeight(void)" (?GetHeight@Image@Gdiplus@@QAEIXZ) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 2 error LNK2019: unresolved external symbol _GdipFree@4 referenced in function "public: static void __cdecl Gdiplus::GdiplusBase::operator delete(void *)" (??3GdiplusBase@Gdiplus@@SAXPAX@Z) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 8 error LNK2019: unresolved external symbol _GdipDisposeImage@4 referenced in function "public: virtual __thiscall Gdiplus::Image::~Image(void)" (??1Image@Gdiplus@@UAE@XZ) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 7 error LNK2019: unresolved external symbol _GdipCloneImage@8 referenced in function "public: virtual class Gdiplus::Image * __thiscall Gdiplus::Image::Clone(void)" (?Clone@Image@Gdiplus@@UAEPAV12@XZ) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 1 error LNK2019: unresolved external symbol _GdipAlloc@4 referenced in function "public: static void * __cdecl Gdiplus::GdiplusBase::operator new(unsigned int)" (??2GdiplusBase@Gdiplus@@SAPAXI@Z) c:\Users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.obj ConsoleApplication4
Error 11 error LNK1120: 10 unresolved externals c:\users\администратор\documents\visual studio 2012\Projects\ConsoleApplication4\Debug\ConsoleApplication4.exe ConsoleApplication4
在gdiplusinit.h中,我看到GdiplusStartupInput,GdiplusStartupOutput,DebugEventLevel模棱两可。有谁知道如何解决?
最佳答案
这里没有歧义,您只是忘记了链接gdiplus.lib。将其添加到链接器的“输入+其他依赖项”设置。
一种简单的方法是将link指令放在源代码中:
#include <windows.h>
#include <gdiplus.h>
#pragma comment(lib,"gdiplus.lib")
关于c++ - gdiplus成员是模棱两可的,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19495508/