Is dwmapi an DLL or a static library?
If static library, I have always used a full path to the library because I have never gotten -llibname to work with an static MSys2 library.
Edit: It appears to be a windows system DLL and not an MSys2 DLL, I have not had this problem. So, my solution may or may not work with an import library to an system DLL.
Edit2: If you attach your CB project and the c/c++ source files with the header files (as a single zip or 7z file), I can try to build it. I have MSys2 installed.
Tim S.