GDI+ Linker Errors

Started by
2 comments, last by vovansim 18 years, 1 month ago
Hi, I'm trying to learn GDI+, but I can't even get the basics to run right. Somehow I get all these linker errors and I have no idear how to correctly set the directories in vc2005. Can anyone please give me directions? Thanks
Advertisement
Please post the errors you're getting, along with code snippets of where the errors are occuring.

As for the directory problem, I've seen that be answered a number of times in the forums, so just look around for that.
Yes, Sorry I didn't do that in the first place. The program I'm writing is because I'm trying to lear GDI+. First the errors, I haven't copied them all, because they are all linker errors, but here are a few (17 in total):

Linking...
Winmain.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "void __stdcall `vector constructor iterator'(void *,unsigned int,int,void * (__thiscall*)(void *))" (??_H@YGXPAXIHP6EPAX0@Z@Z)
Winmain.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
Winmain.obj : error LNK2001: unresolved external symbol __RTC_InitBase
Winmain.obj : error LNK2019: unresolved external symbol ___security_cookie referenced in function "void __cdecl OnPaint(struct HDC__ *)" (?OnPaint@@YAXPAUHDC__@@@Z)
Winmain.obj : error LNK2019: unresolved external symbol ___CxxFrameHandler3 referenced in function __ehhandler$?OnPaint@@YAXPAUHDC__@@@Z
Winmain.obj : error LNK2019: unresolved external symbol @__security_check_cookie@4 referenced in function __ehhandler$?OnPaint@@YAXPAUHDC__@@@Z
Winmain.obj : error LNK2001: unresolved external symbol __fltused
Winmain.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "void __cdecl OnPaint(struct HDC__ *)" (?OnPaint@@YAXPAUHDC__@@@Z)
Winmain.obj : error LNK2019: unresolved external symbol _GdipCreatePen1@16 referenced in function "public: __thiscall Gdiplus::Pen::Pen(class Gdiplus::Color const &,float)" (??0Pen@Gdiplus@@QAE@ABVColor@1@M@Z)
Winmain.obj : error LNK2019: unresolved external symbol _GdipDeletePen@4 referenced in function "public: __thiscall Gdiplus::Pen::~Pen(void)" (??1Pen@Gdiplus@@QAE@XZ)
Winmain.obj : error LNK2019: unresolved external symbol _GdipCreateFromHDC@8 referenced in function "public: __thiscall Gdiplus::Graphics::Graphics(struct HDC__ *)" (??0Graphics@Gdiplus@@QAE@PAUHDC__@@@Z)
Winmain.obj : error LNK2019: unresolved external symbol _GdipDeleteGraphics@4 referenced in function "public: __thiscall Gdiplus::Graphics::~Graphics(void)" (??1Graphics@Gdiplus@@QAE@XZ)
Winmain.obj : error LNK2019: unresolved external symbol _GdipDrawLineI@24 referenced in function "public: enum Gdiplus::Status __thiscall Gdiplus::Graphics::DrawLine(class Gdiplus::Pen const *,int,int,int,int)" (?DrawLine@Graphics@Gdiplus@@QAE?AW4Status@2@PBVPen@2@HHHH@Z)
Winmain.obj : error LNK2019: unresolved external symbol _GdiplusShutdown@4 referenced in function _WinMain@16
Winmain.obj : error LNK2019: unresolved external symbol _GdiplusStartup@12 referenced in function _WinMain@16
LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup

From the program, the paint section (where the gdi+ code is):

hdc = BeginPaint(hwnd, &ps);
OnPaint(hdc);
EndPaint(hwnd, &ps);
return 0;

And the OnPaint() function:

void OnPaint(HDC hdc){
Graphics graphics(hdc);
Pen pen(Color(255,0,0,255));
graphics.DrawLine(&pen,0,0,200,100);
}

I've been looking throught the forums for a discussion on setting up VC2005 the correct way for GDI+ but couldn't find it. Hope someone can help me with this! Thanks!
I'm guessing you aren't linking with GDI+. In order to do that, right-click your project in the solution explorer, and hit "properties". Then in the tree on the left of the porject properties window, expand: Configuration Properties->Linker->Input. Put gdiplus.lib into the "Additional Dependencies" field. If the library cannot be found, add the path to the library into Configuration Propreties->Linker->General->Additinal Library Directories. You will also need to have gdiplus.dll in the same directory as your executable when you run it, else the thing will crash on startup.

Vovan
Vovan

This topic is closed to new replies.

Advertisement