Search code examples
c++static-librarieslinker-errors

Where to download C++ WinApi libraries if there is only `.h` file in compiler folder?


I've recently installed mingw-w64-ucrt-x86_64-toolchain, acting according to this instruction. I thought that everything is fine until met undefined reference error with shellscalingapi. The weird moment here is that I've found the header (shellscalingapi.h), but there is no the library itself anywhere in C:\msys64\ucrt64 (tried recursive search).

This code compiles...

#include <shellscalingapi.h>

int main(){
    SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE);
    return 0;
}

But on linking stage it says: "undefined reference to `SetProcessDpiAwareness'"

Can anyone tell how to download missing libraries?


Solution

  • You don't need to install anything extra to use WinAPI.

    Google the specific function you have problem with, find the manual.

    Notice Library: Shcore.lib. This means you need to add -lshcore to the linker flags. This will link libshcore.a that comes with your compiler.