Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to `GdiplusStartup@12'

Tags:

c++

g++

linker

gdi+

I'm finding a way to use GDI+ library with g++ compiler, I have read some guildlines on the web and still meet with problem...
Here is my code:

#include "gdiplus.h"  
using namespace Gdiplus;

// Skip Lines

GdiplusStartup(&lpGdiplusToken, &gdiplusStartupInput, &gdiplusStartupOutput);
// Skip Lines  

And I have already used the compiler switch as below:

g++ -Wall -mwindows -lgdiplus -I"C:\MinGW\include" -I"C:\MinGW\include\gdiplus" -L"C:\MinGW\lib" -g3 -finput-charset=GBK "$(FilePath)" -o "$(FileDir)\$(FileNameNoExt).exe"

Still I got such errors:

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccjX3mCb.o: In function `WinMain@16':
D:/Projects/cyau/cyau_pre4_20120226/cyau_main.cpp:65: undefined reference to `GdiplusStartup@12'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccjX3mCb.o: In function `Z15ExitApplicationP6HWND__jjl':
D:/Projects/cyau/cyau_pre4_20120226/cyau_main.cpp:128: undefined reference to `GdiplusShutdown@4'

So what's wrong with it? Is there anything more I need?
Thanks for help...

like image 716
cuter44 Avatar asked Mar 03 '12 01:03

cuter44


1 Answers

I had similar messages as you and after some research I've come to the following: place -lgdiplus after *.cpp files on the command line. Example:

g++ -mwindows program.cpp -lgdiplus

That command compiled my GDI+ program.

like image 160
user1257 Avatar answered Oct 07 '22 01:10

user1257