mingw reports undefined reference to functions in gdi32, undefined reference to `__imp_CreateCompatibleDC' error solution

When compiling pdfium-master, mingw always reports the following errors

PS D:\projectcode\PDFium-master\biuld> make fx_win32_c_all
 compiling:    fx_win32_device.o  fx_win32_dib.o  fx_win32_dwrite.o  fx_win32_gdipext.o  fx_win32_print.o
PS D:\projectcode\PDFium-master\biuld> make
../sdk/src/fpdf_dataavail.cpp: In member function 'virtual FX_BOOL CFPDF_FileAccessWrap::ReadBlock(void*, FX_INT32, size_t)':
../sdk/src/fpdf_dataavail.cpp:64:55: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
                 memcpy(buffer, m_pFileAccess->m_Param + offset, size);
                                ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
../sdk/src/fpdf_dataavail.cpp: In member function 'virtual FX_BOOL CPDF_CustomAccess::ReadBlock(void*, FX_INT32, size_t)':
../sdk/src/fpdf_dataavail.cpp:108:95: warning: no return statement in function returning non-void [-Wreturn-type]
         virtual FX_BOOL ReadBlock(void *buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE {
    
    }
                                                                                               ^
fx_win32_device.o:fx_win32_device.cpp:(.text+0xf8): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x250): undefined reference to `__imp_DeleteDC'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x290): undefined reference to `__imp_CreateFontIndirectA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3aa): undefined reference to `__imp_CreateFontIndirectA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x83f): undefined reference to `__imp_EnumFontFamiliesExA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x1c33): undefined reference to `__imp_CreateFontA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x1c5f): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x1c8c): undefined reference to `__imp_GetTextFaceA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x1cb0): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x1e3a): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x202a): undefined reference to `__imp_CreateFontA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x216c): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x21a4): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2208): undefined reference to `__imp_GetFontData'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2223): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2269): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x228d): undefined reference to `__imp_GetTextFaceA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x22a8): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2300): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x231c): undefined reference to `__imp_GetTextMetricsA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2334): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x281c): undefined reference to `__imp_SetStretchBltMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x283a): undefined reference to `__imp_GetObjectType'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2870): undefined reference to `__imp_CreateBitmap'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x288f): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x28af): undefined reference to `__imp_GetObjectA'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x28fe): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2912): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2930): undefined reference to `__imp_GetDeviceCaps'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x295f): undefined reference to `__imp_GetDeviceCaps'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2987): undefined reference to `__imp_GetDeviceCaps'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2ae9): undefined reference to `__imp_CreateRectRgn'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2b05): undefined reference to `__imp_GetClipRgn'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2b1e): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x2e6a): undefined reference to `__imp_StretchDIBits'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x305f): undefined reference to `__imp_SetDIBitsToDevice'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x339c): undefined reference to `__imp_SetStretchBltMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x33c1): undefined reference to `__imp_SetStretchBltMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3583): undefined reference to `__imp_StretchDIBits'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3785): undefined reference to `__imp_SetStretchBltMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x380c): undefined reference to `__imp_StretchDIBits'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3842): undefined reference to `__imp_GetClipBox'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3870): undefined reference to `__imp_SelectClipRgn'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3b1f): undefined reference to `__imp_ExtCreatePen'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3b77): undefined reference to `__imp_CreateSolidBrush'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3b9f): undefined reference to `__imp_BeginPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3ca4): undefined reference to `__imp_MoveToEx'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3d6b): undefined reference to `__imp_LineTo'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3eba): undefined reference to `__imp_PolyBezierTo'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3ef2): undefined reference to `__imp_CloseFigure'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x3f08): undefined reference to `__imp_EndPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x413b): undefined reference to `__imp_MoveToEx'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x416e): undefined reference to `__imp_LineTo'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x45e6): undefined reference to `__imp_SetMiterLimit'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4618): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x463f): undefined reference to `__imp_SetPolyFillMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4665): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x47cd): undefined reference to `__imp_StrokeAndFillPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x47e3): undefined reference to `__imp_FillPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4812): undefined reference to `__imp_StrokePath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4828): undefined reference to `__imp_StrokePath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x484c): undefined reference to `__imp_FillPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x486b): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x487f): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x489e): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x48b2): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x494e): undefined reference to `__imp_CreateSolidBrush'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4981): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4a1c): undefined reference to `__imp_IntersectClipRect'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4a5a): undefined reference to `__imp_SetPolyFillMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4a73): undefined reference to `__imp_SelectClipPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4ac8): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4afb): undefined reference to `__imp_WidenPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4b14): undefined reference to `__imp_SetPolyFillMode'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4b2d): undefined reference to `__imp_SelectClipPath'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4b48): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4b5c): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4bfa): undefined reference to `__imp_CreatePen'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4c16): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4c53): undefined reference to `__imp_MoveToEx'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4c86): undefined reference to `__imp_LineTo'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4c9e): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4cb2): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4cde): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4fb6): undefined reference to `__imp_CreateCompatibleBitmap'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4fdb): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x4ffc): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x5061): undefined reference to `__imp_BitBlt'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x507b): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x528f): undefined reference to `__imp_GetDIBits'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x535c): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x5376): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6703): undefined reference to `__imp_GetDeviceCaps'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x674d): undefined reference to `__imp_ExtEscape'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x678d): undefined reference to `__imp_ExtEscape'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x67d5): undefined reference to `__imp_ExtEscape'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6815): undefined reference to `__imp_ExtEscape'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6869): undefined reference to `__imp_ExtEscape'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x68b3): more undefined references to `__imp_ExtEscape' follow
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6c70): undefined reference to `__imp_GetDeviceCaps'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6c8a): undefined reference to `__imp_GetObjectType'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6f27): undefined reference to `__imp_CreateDIBSection'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x6fd9): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x7009): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x71c6): undefined reference to `__imp_SelectObject'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x71e1): undefined reference to `__imp_DeleteDC'
fx_win32_device.o:fx_win32_device.cpp:(.text+0x7202): undefined reference to `__imp_DeleteObject'
fx_win32_device.o:fx_win32_device.cpp:(.text$_ZN16CGdiDeviceDriver9SaveStateEv[_ZN16CGdiDeviceDriver9SaveStateEv]+0x1a): undefined reference to `__imp_SaveDC'
fx_win32_device.o:fx_win32_device.cpp:(.text$_ZN16CGdiDeviceDriver12RestoreStateEi[_ZN16CGdiDeviceDriver12RestoreStateEi]+0x22): undefined reference to `__imp_RestoreDC'
fx_win32_device.o:fx_win32_device.cpp:(.text$_ZN16CGdiDeviceDriver12RestoreStateEi[_ZN16CGdiDeviceDriver12RestoreStateEi]+0x3c): undefined reference to `__imp_SaveDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xa18): undefined reference to `__imp_CreateDIBitmap'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xaf8): undefined reference to `__imp_GetObjectA'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xcaf): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xd22): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xdb5): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xe62): undefined reference to `__imp_GetDIBits'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0xec0): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1189): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x11f6): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1283): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1327): undefined reference to `__imp_GetDIBits'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x137f): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x156a): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x15d3): undefined reference to `__imp_GetDIBits'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x16e8): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x17e2): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1859): undefined reference to `__imp_GetDIBits'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1946): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x19ba): undefined reference to `__imp_GetDIBits'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1ae7): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1d2d): undefined reference to `__imp_CreateDIBSection'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1d4e): undefined reference to `__imp_CreateCompatibleDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1d7e): undefined reference to `__imp_SelectObject'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1e7d): undefined reference to `__imp_SelectObject'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1e98): undefined reference to `__imp_DeleteDC'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1eac): undefined reference to `__imp_DeleteObject'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1f62): undefined reference to `__imp_BitBlt'
fx_win32_dib.o:fx_win32_dib.cpp:(.text+0x1fd4): undefined reference to `__imp_BitBlt'
fx_win32_dwrite.o:fx_win32_dwrite.cpp:(.text+0xf37): undefined reference to `__imp_GetCurrentObject'
fx_win32_dwrite.o:fx_win32_dwrite.cpp:(.text+0xf60): undefined reference to `__imp_GetObjectA'
fx_win32_dwrite.o:fx_win32_dwrite.cpp:(.rdata$.refptr.IID_IUnknown[.refptr.IID_IUnknown]+0x0): undefined reference to `IID_IUnknown'
fx_win32_print.o:fx_win32_print.cpp:(.text+0xe8): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x117): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x1f8e): undefined reference to `__imp_ExtEscape'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x22ed): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x231c): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x2344): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x236c): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x2394): undefined reference to `__imp_GetDeviceCaps'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x2482): undefined reference to `__imp_CreateRectRgn'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x249d): undefined reference to `__imp_GetClipRgn'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x24c5): undefined reference to `__imp_GetRegionData'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x2513): undefined reference to `__imp_GetRegionData'
fx_win32_print.o:fx_win32_print.cpp:(.text+0x2621): undefined reference to `__imp_DeleteObject'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:114: all] Error 1
PS D:\projectcode\PDFium-master\biuld> make
../sdk/src/fpdf_dataavail.cpp: In member function 'virtual FX_BOOL CFPDF_FileAccessWrap::ReadBlock(void*, FX_INT32, size_t)':
../sdk/src/fpdf_dataavail.cpp:64:55: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
                 memcpy(buffer, m_pFileAccess->m_Param + offset, size);
                                ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
../sdk/src/fpdf_dataavail.cpp: In member function 'virtual FX_BOOL CPDF_CustomAccess::ReadBlock(void*, FX_INT32, size_t)':
../sdk/src/fpdf_dataavail.cpp:108:95: warning: no return statement in function returning non-void [-Wreturn-type]
         virtual FX_BOOL ReadBlock(void *buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE {
    
    }
                                                                                               ^
fx_win32_dwrite.o:fx_win32_dwrite.cpp:(.rdata$.refptr.IID_IUnknown[.refptr.IID_IUnknown]+0x0): undefined reference to `IID_IUnknown'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:114: all] Error 1
PS D:\projectcode\PDFium-master\biuld>

Then in the makefile, add -lgdi32 to the link and pass.

all: $(pdf_dep) 
	g++ -o pdfmaster_3 $(pdf_obj)  libjpeg.o  lcms2_26.o  libopenjpeg20.o  libhellofreetype.a  -lgdi32
.PHONY : pdfmaster1

Guess you like

Origin blog.csdn.net/yangjia_cheng/article/details/115528130