Search code examples
c++fltk

Which static library should I link when using wingdi.h?


Recently I've tried FLTK. After I compiled the source code, I want to create a tiny application using FLTK.

code

However, after I tried to complie it, g++ said:

C:\Program Files (x86)\FLTK\lib/libfltk.a(Fl_Window_shape.cxx.obj):Fl_Window_shape.cxx:(.text+0x298): undefined reference to '__imp_ExtCreateRegion' 
C:\Program Files (x86)\FLTK\lib/libfltk.a(Fl_Window_shape.cxx.obj):Fl_Window_shape.cxx:(.text+0x2c4): undefined reference to '__imp_CombineRgn'
C:\Program Files (x86)\FLTK\lib/libfltk.a(Fl_Window_shape.cxx.obj):Fl_Window_shape.cxx:(.text+0x2d4): undefined reference to '__imp_DeleteObject'
C:\Program Files (x86)\FLTK\lib/libfltk.a(Fl_Window_shape.cxx.obj):Fl_Window_shape.cxx:(.text+0x351): undefined reference to '__imp_ExtCreateRegion'
C:\Program Files (x86)\FLTK\lib/libfltk.a(Fl_Window_shape.cxx.obj):Fl_Window_shape.cxx:(.text+0x37d): undefined reference to '__imp_CombineRgn'
C:\Program Files (x86)\FLTK\lib/libfltk.a(Fl_Window_shape.cxx.obj):Fl_Window_shape.cxx:(.text+0x38d): undefined reference to '__imp_DeleteObject'
C:\Program Files (x86)\FLTK\lib/libfltk.a(fl_color.cxx.obj):fl_color.cxx:(.text+0x65): undefined reference to '__imp_DeleteObject'
C:\Program Files (x86)\FLTK\lib/libfltk.a(fl_color.cxx.obj):fl_color.cxx:(.text+0x9f): undefined reference to '__imp_CreatePen'
C:\Program Files (x86)\FLTK\lib/libfltk.a(fl_color.cxx.obj):fl_color.cxx:(.text+0xc3): undefined reference to '__imp_SelectObject'
C:\Program Files (x86)\FLTK\lib/libfltk.a(fl_color.cxx.obj):fl_color.cxx:(.text+0x102): undefined reference to '__imp_SelectObject'

And a lot more. I figured out that ExtCreateRegion and other mentioned functions are in windgi.h. So, which static library should I link to?


Solution

  • Most functions declared in wingdi.h require linking to gdi32.lib.

    For example, ExtCreateRegion is documented here, and among the details at the bottom of that page are:

    • Header:     wingdi.h  (include Windows.h)

    • Library:     Gdi32.lib

    • DLL:         Gdi32.dll

    which static library should I link?

    gdi32.lib is not a static library, but rather is an import library that references gdi32.dll, which will be loaded at runtime and contains the actual function.