Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!
Strona główna C++ C++ Hardware HTML i javascript Java Software SQL

C++ - GDI+ compiling examples of Microsoft, and the most common problems with them.

Added: 2012-01-10

Windows GDI+ is very useful for the programmer's C++, which is working in Visual Studio. Opportunities offered by the library are large, you can create a simple application that converts images to others.

On page Microsoft you can find example and documentation GDI+. While compiling the example, you can have a problem.

  • error LNK2019: unresolved external symbol "int __cdecl GetEncoderClsid(wchar_t const *,struct _GUID *)" (?GetEncoderClsid@@YAHPB_WPAU_GUID@@@Z) referenced in function _main

    Problem that is, because you must implement GetEncoderClsid(). Implemented function below:

    int GetEncoderClsid(const WCHAR* format, CLSID* pClsid){
    	 UINT num = 0; 
    	 UINT size = 0; 
    	 GetImageEncodersSize(&num, &size);
    	 if(size == 0)
    		return -1; 
    	 ImageCodecInfo* pICI = new ImageCodecInfo[size];
    		return -1;
    	 GetImageEncoders(num, size, pICI);
    	 for(UINT j=0; j<num; ++j)
    		if(wcscmp(pICI[j].MimeType, format) == 0){
    			*pClsid = pICI[j].Clsid;
    			delete[] pICI;
    			return j;
    	 delete[] pICI;
    	 return -1;
  • error LNK2019: unresolved external symbol _GdipDisposeImage@4 referenced in function "public: virtual __thiscall Gdiplus::Image::~Image(void)" (??1Image@Gdiplus@@UAE@XZ)

    This problem, can you fix easy, adding static library. #pragma comment(lib, "gdiplus.lib")

Now you can build example.