3

我正在尝试 在 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.hi 中看到 GdiplusStartupInput,GdiplusStartupOutput,DebugEventLevel 是模棱两可的。有谁知道如何解决这个问题?

4

2 回答 2

18

这里没有歧义,您只是忘记链接 gdiplus.lib。将其添加到链接器的 Input + Additional Dependencies 设置中。

一种简单的方法是将链接指令放在源代码中:

#include <windows.h>
#include <gdiplus.h>
#pragma comment(lib,"gdiplus.lib")
于 2013-10-21T13:18:23.163 回答
1

您发布的所有错误都是链接器未解决的符号。您似乎忘记在 VS 项目中添加一个库(类似于gdi.libor )。gdiplus.lib

于 2013-10-21T13:15:57.050 回答