cuziyq
asked on
Unresolved external symbol errors working with <gdiplus.h>
This one has got me puzzled.
I am trying to work with Microsoft's GDI+ API and I keep getting 'Unresolved external symbol' errors from the linker. I created a brand new (empty) Win32 Application project and copied Microsoft's example code verbatim from this MSDN page: http://msdn.microsoft.com/en-us/library/ms533895(VS.85).aspx
When I try to build the project, I keep coming back to these same unresolved external symbol errors:
error LNK2019: unresolved external symbol _GdipCreatePen1@16 referenced in function "public: __thiscall Gdiplus::Pen::Pen(class Gdiplus::Color const &,float)" (??0Pen@Gdiplus@@QAE@ABVCo lor@1@M@Z) TestGDI.obj
error LNK2019: unresolved external symbol _GdipDeletePen@4 referenced in function "public: __thiscall Gdiplus::Pen::~Pen(void)" (??1Pen@Gdiplus@@QAE@XZ) TestGDI.obj
error LNK2019: unresolved external symbol _GdipCreateFromHDC@8 referenced in function "public: __thiscall Gdiplus::Graphics::Graphic s(struct HDC__ *)" (??0Graphics@Gdiplus@@QAE@ PAUHDC__@@ @Z) TestGDI.obj
error LNK2019: unresolved external symbol _GdipDeleteGraphics@4 referenced in function "public: __thiscall Gdiplus::Graphics::~Graphi cs(void)" (??1Graphics@Gdiplus@@QAE@ XZ) TestGDI.obj
error LNK2019: unresolved external symbol _GdipDrawLineI@24 referenced in function "public: enum Gdiplus::Status __thiscall Gdiplus::Graphics::DrawLin e(class Gdiplus::Pen const *,int,int,int,int)" (?DrawLine@Graphics@Gdiplu s@@QAE?AW4 Status@2@P BVPen@2@HH HH@Z) TestGDI.obj
error LNK2019: unresolved external symbol _GdiplusShutdown@4 referenced in function _WinMain@16 TestGDI.obj
error LNK2019: unresolved external symbol _GdiplusStartup@12 referenced in function _WinMain@16 TestGDI.obj
fatal error LNK1120: 7 unresolved externals
I am working with a fresh install of Visual Studio 2008, and have verified that the include and library search paths are set up correctly in Tools->Options. The system finds the headers just fine.
I am trying to work with Microsoft's GDI+ API and I keep getting 'Unresolved external symbol' errors from the linker. I created a brand new (empty) Win32 Application project and copied Microsoft's example code verbatim from this MSDN page: http://msdn.microsoft.com/en-us/library/ms533895(VS.85).aspx
When I try to build the project, I keep coming back to these same unresolved external symbol errors:
error LNK2019: unresolved external symbol _GdipCreatePen1@16 referenced in function "public: __thiscall Gdiplus::Pen::Pen(class Gdiplus::Color const &,float)" (??0Pen@Gdiplus@@QAE@ABVCo
error LNK2019: unresolved external symbol _GdipDeletePen@4 referenced in function "public: __thiscall Gdiplus::Pen::~Pen(void)" (??1Pen@Gdiplus@@QAE@XZ) TestGDI.obj
error LNK2019: unresolved external symbol _GdipCreateFromHDC@8 referenced in function "public: __thiscall Gdiplus::Graphics::Graphic
error LNK2019: unresolved external symbol _GdipDeleteGraphics@4 referenced in function "public: __thiscall Gdiplus::Graphics::~Graphi
error LNK2019: unresolved external symbol _GdipDrawLineI@24 referenced in function "public: enum Gdiplus::Status __thiscall Gdiplus::Graphics::DrawLin
error LNK2019: unresolved external symbol _GdiplusShutdown@4 referenced in function _WinMain@16 TestGDI.obj
error LNK2019: unresolved external symbol _GdiplusStartup@12 referenced in function _WinMain@16 TestGDI.obj
fatal error LNK1120: 7 unresolved externals
I am working with a fresh install of Visual Studio 2008, and have verified that the include and library search paths are set up correctly in Tools->Options. The system finds the headers just fine.
Sample code from Microsoft's web site -- copied verbatim into a new project. No joy :(
#define UNICODE
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
VOID OnPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawLine(&pen, 0, 0, 200, 100);
}
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("GettingStarted");
RegisterClass(&wndClass);
hWnd = CreateWindow(
TEXT("GettingStarted"), // window class name
TEXT("Getting Started"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GdiplusShutdown(gdiplusToken);
return msg.wParam;
} // WinMain
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
} // WndProc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, they're not making a secret out of that ;o) E.g. the docs for 'GdiplusStartup()' (http://msdn.microsoft.com/en-us/library/ms534077(VS.85).aspx) state:
Stock Implementation gdiplus.dll
Header Declared in Gdiplusinit.h, include gdiplus.h
Import library gdiplus.lib <----
Yet I agree that they could have mentioned that on that example page also.
Stock Implementation gdiplus.dll
Header Declared in Gdiplusinit.h, include gdiplus.h
Import library gdiplus.lib <----
Yet I agree that they could have mentioned that on that example page also.
Hm, any further problems?
ASKER
Sorry. Forgot to close the question and award the points.
ASKER
See, now I am pissed. Why would Microsoft's documentation for the damn thing carry on like all you had to do is #include the appropriate headers? I mean seriously . . . why couldn't they have put a SINGLE sentence in their "Getting Started" guide that says something like "oh, by the way, to actually USE this crap, you have to ..."
Sorry I am just ranting here. I hate it when my time gets wasted on frivilous pursuits.
Thank you, BTW :-)