Search code examples
c++dllwindows-runtimevcpkg

WinRT DLL in UWP app crashes when using dependencies from VCPKG


I created an SDK using WINRT because it's the most flexible and I can use it outside UWP apps without having to maintain another SDK for native platforms at the same time. I am using VCPKG as my package manager because it's very easy to maintain. The issue is that if I include a dependency like cpr in the SDK and then try to run in the UWP app I end up with a missing DLL error. If I remove include cpr.h and then just use a test printf in the SDK and try it from the UWP app it works, so I guess something is wrong with third party dependencies when the SDK DLL is being exported. Any idea on how to fix this?


Solution

  • Apparently this isn't mentioned anywhere in Microsoft documentation but you should copy your dependencies to bin\x64\Debug\AppX or bin\x86\Debug\AppX If you're running 32 bit. You can do this as part of the build process by going to properties > Build Events > Post-Build Event and adding copy commands to the above build directory.