Search code examples
visual-studiostatic-linkingmsvcrt

MSVC17 Linking application with runtime statically, still getting missing dll error


I set /MT flag to have my c++ application statically linked with C runtime, so I don't have to worry about redistributing the runtime, however, upon launch I get an error message saying missing "Api-ms-win-core-version-l1-1-0.dll". How do I compile my application so that its completely independent of any runtime etc?

Build Environment: MSVC 2017, windows 10 SDK Compile and Test machine: 64-Bit Windows 7


Solution

  • The selected answer here helped me solve my problem. In short, you can't link with any of the api-ms-win-core* libraries, you should link with appropriate libraries listed for APIs in the msdn. The api-ms-win-core* libraries are used indirectly by the OS, that's why they show up as missing - when in reality the appropriate windows .lib need to be linked.

    In my case, I used depends to figure out which API libraries were missing then looked up the appropriate .lib files in msdn and added those in "additional dependencies". Problem solved.

    FYI, /MT flag is working as expected, I don't have to redistribute c-runtime etc.