So, I have project written on C and need to draw PNG in the window created by the WinApi. I decided to use GDI+ and to create one c++ source file, linked to general project. There it is:
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
void drawPNG (HWND hwnd, unsigned xpos, unsigned ypos, char * rid) {
PAINTSTRUCT ps;
HDC dc = BeginPaint (hwnd, &ps);
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Rect rect(20,20,50,50);
Graphics grpx(dc);
Image* image = new Image(L"SomePhoto.png");
grpx.DrawImage(image,rect);
delete image;
GdiplusShutdown(gdiplusToken);
EndPaint(hwnd, &ps);
}
I try to compile it with:
gcc -lstdc++ -x c++ img_drawing.c -lgdiplus -mwindows
And got these errors:
img_drawing.o:img_drawing.c:(.text+0x5d): undefined reference to `GdiplusStartup@12'
img_drawing.o:img_drawing.c:(.text+0x105): undefined reference to `GdiplusShutdown@4'
img_drawing.o:img_drawing.c:(.text$_ZN7Gdiplus11GdiplusBasenwEj[__ZN7Gdiplus11GdiplusBasenwEj]+0xfffffa09): undefined reference to `GdipAlloc@4'
But if I try to use g++, it builds without errors:
g++ img_drawing.c -lgdiplus -mwindows
I use MinGW compiler on Windows 7. Any idea why it's compiling with errors with the first command?