Linker errors when adding a native c++ static library to Windows runtime component (UWP)

67 Views Asked by At

Adding a native C++ library to Windows runtime component (C++ Winrt) project throws error (LINK : fatal error LNK1104: cannot open file 'comsuppw.lib').

I have followed https://learn.microsoft.com/en-us/cpp/porting/how-to-use-existing-cpp-code-in-a-universal-windows-platform-app?view=msvc-170#BK_StaticLib page to set the project settings

Added all the missing msvc .lib files ("msvc\comsuppw.lib" "msvc\libcmt.lib" "msvc\libvcruntime.lib") which throws unresolved external errors for the 3rd-party dependencies of the project.

How to verify if C++ project library is compatible for UWP project?

1

There are 1 best solutions below

2
Junjie Zhu - MSFT On

UWP Apps run in a protected environment. As a result, many Win32, COM, and CRT API calls that might compromise platform security aren't allowed. The /ZW compiler option can detect such calls and generate an error.

The third-party libraries which include unsupported API cannot be used in UWP, you can check the Win32API supported in UWP

If you want to use the native C++ library which include unsupported API in UWP project, you can try Desktop Bridge technologies. For more infromation, you can search Stefan Wick's blog UWP with Desktop Extension – Part 1.