I'm trying to use the x86_64-w64-mingw32-g++
utility to compile a Win64 binary on my Debian machine. I'm running into an issue with undefined reference *
linker errors even though I'm passing the libraries to the linker:
# /usr/bin/x86_64-w64-mingw32-g++ -lgdi32 -luser32 -lkernel32 -lcomctl32 -m64 -o main.exe main.cpp code.obj
/tmp/ccSKB1pW.o:main.cpp:(.text+0x82a): undefined reference to `__imp_CreateCompatibleDC'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x847): undefined reference to `__imp_CreateCompatibleBitmap'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x85f): undefined reference to `__imp_SelectObject'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x871): undefined reference to `__imp_CreateSolidBrush'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x8da): undefined reference to `__imp_BitBlt'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x8ee): undefined reference to `__imp_SelectObject'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x8fe): undefined reference to `__imp_DeleteObject'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x90e): undefined reference to `__imp_DeleteDC'
collect2: error: ld returned 1 exit status
I'm not able to find much information about this issue online. Any idea why it's not finding the symbols in the libraries?
Edit: As far as I can tell, a GDI library was provided by the debian package:
# dpkg -L mingw-w64-x86-64-dev | grep gdi32
/usr/x86_64-w64-mingw32/lib/libgdi32.a
Additionally, I am able to find the symbols in the library file:
# objdump -t /usr/x86_64-w64-mingw32/lib/libgdi32.a | grep CreateCompat
[ 7](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 CreateCompatibleDC
[ 8](sec 5)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_CreateCompatibleDC
[ 7](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 CreateCompatibleBitmap
[ 8](sec 5)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_CreateCompatibleBitmap