Undefined link to `GdiplusStartup @ 12 '

I find a way to use the GDI + library with the g ++ compiler, I read several guild lines on the Internet and still encounter a problem ...
Here is my code:

#include "gdiplus.h" using namespace Gdiplus; // Skip Lines GdiplusStartup(&lpGdiplusToken, &gdiplusStartupInput, &gdiplusStartupOutput); // Skip Lines 

And I already used the compiler switch as shown 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" 

However, I got the following 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 ' 

And what's wrong with that? Is there anything else I need?
Thanks for the help...

+4
source share
3 answers

I had similar messages like you, and after some research I came to the following: put -lgdiplus after *.cpp files on the command line. Example:

 g++ -mwindows program.cpp -lgdiplus 

This command compiled my GDI + program.

+4
source

I am using DevCPP and have the same problem.

Creating libgdiplus.a from gdiplus.def with this command solved my problem:

 dlltool -k -d gdiplus.def -l libgdiplus.a 

At first I used the command above without the -k options.

+1
source

I have no experience with g ++, but I believe the problem is with binding.

Either the gdiplus library does not link, or it does not map to g ++. Hope this helps you keep looking for the problem.

0
source

Source: https://habr.com/ru/post/1399498/


All Articles