The article this was marked as a duplicate of doesn't help since it addresses general linker problems, but not this specific one.
I am trying to port a small C++ program I wrote for Linux using Boost, SQLite and GTK+3 to Windows. The code compiles just fine, but am encountering a linking issue that I can't seem to solve. I am relatively new to the C++ world, so hopefully the problem is fairly easy to fix. I've searched the internet for the past 2 days and haven't found anything that helps, so I'm now asking here.
On Linux, I am using g++ and so I've setup mingw with msys2 on Windows 10. I've installed the necessary libraries using pacman in msys2:
pacman -S base-devel mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-gtk3 mingw-w64-x86_64-pkg-config mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-boost
and the command I am using to link is:
g++ \
-Wall -g -std=c++11 -no-pie \
-o bin/developersnotebook.exe \
-lsqlite3 -lboost_system-mt -lboost_filesystem-mt \
`pkg-config --libs gtk+-3.0` \
build/components/Modal.o build/db/SqliteConnectionManager.o [...]
It has no problem linking libsqlite3, libboost_system-mt and libboost_filesystem-mt, but I still get the following error:
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -ldwmapi
I've tried to include the path C:\Windows\SysWOW64 where dwmapi.dll is located like this:
g++ \
-Wall -g -std=c++11 -no-pie \
-o bin/developersnotebook.exe \
-lsqlite3 -lboost_system-mt -lboost_filesystem-mt -L"C:\Windows\SysWOW64" \
`pkg-config --libs gtk+-3.0` \
build/components/Modal.o build/db/SqliteConnectionManager.o [...]
but that only produces more errors:
Warning: resolving _SetUnhandledExceptionFilter@4 by linking to _SetUnhandledExceptionFilter
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _ExitProcess@4 by linking to _ExitProcess
Warning: resolving _GetModuleHandleA@4 by linking to _GetModuleHandleA
Warning: resolving _GetProcAddress@8 by linking to _GetProcAddress
Warning: resolving _FreeLibrary@4 by linking to _FreeLibrary
Warning: resolving _GetCommandLineA@0 by linking to _GetCommandLineA
Warning: resolving _EnterCriticalSection@4 by linking to _EnterCriticalSection
Warning: resolving _TlsGetValue@4 by linking to _TlsGetValue
Warning: resolving _GetLastError@0 by linking to _GetLastError
Warning: resolving _LeaveCriticalSection@4 by linking to _LeaveCriticalSection
Warning: resolving _DeleteCriticalSection@4 by linking to _DeleteCriticalSection
Warning: resolving _VirtualQuery@12 by linking to _VirtualQuery
Warning: resolving _VirtualProtect@16 by linking to _VirtualProtect
Warning: resolving _FindFirstFileA@8 by linking to _FindFirstFileA
Warning: resolving _FindNextFileA@8 by linking to _FindNextFileA
Warning: resolving _FindClose@4 by linking to _FindClose
Warning: resolving _IsDBCSLeadByteEx@8 by linking to _IsDBCSLeadByteEx
Warning: resolving _MultiByteToWideChar@24 by linking to _MultiByteToWideChar
Warning: resolving _WideCharToMultiByte@32 by linking to _WideCharToMultiByte
Warning: resolving _Sleep@4 by linking to _Sleep
Warning: resolving _InterlockedExchange@8 by linking to _InterlockedExchange
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x29): undefined reference to `LoadLibraryA@4'
plus "undefined reference" errors to GTK+, Boost and SQLite.
I am a bit lost as to how to solve this. I've been working on it for the past 2 days and have made no progress at all... Does anyone have any idea? Given the lack of information about it on the internet, I assume it is either a noob problem or is rare.
Thank you in advance!
The project is on Github: https://github.com/eiskalteschatten/developersnotebook