I am working on an application that requires interfacing with Gdi32 and JsonCpp libraries. To keep things simple, I put relevant relevant code-segments in 2 separate files and compiled them individually as binaries. Both applications compiled are run ok.
I used the following commands to compile:
JsonCpp:
g++ -I/mingw64/include/json -L/mingw64/bin -llibjsoncpp-24 my_json.cpp -o my_json.exe -O3
Gdi32:
g++ my_app.cpp -o my_app.exe -lGDI32 -O3
Later I combined the code from those 2 files into a single file and tried to compile with the following command:
g++ -I/mingw64/include/json -L/mingw64/bin -llibjsoncpp-24 -lGDI32 combined.cpp -o combined.exe -O3
This results in the following compiler/linker error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccOLYQ4n.o:combined.cpp:(.text+0x458): undefined reference to `__imp_GetStockObject' collect2.exe: error: ld returned 1 exit status
Could anyone please tell me how to fix this issue?
I am on Window 8 PC, using msys2 (mingw64) g++ ver 10.2.0.