-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Build] Broken binaries for Windows UWP: LNK1181 error missing delayimp.lib and dependency MSVCP140D.dll and VCRUNTIME140D.dll #19495
Comments
I've bisected the LNK1181 missing delayimp.lib error to commit 2cc1a76. Reverting the changes in L.1922-1929 in cmake/CMakeLists.txt produces a working UWP binary, linking to MSVCP140[D]_APP.dll and VCRUNTIME140[D]_APP.dll rather than MSVCP140[D].dll and VCRUNTIME140[D].dll. I'm not expert here, so don't know how to deal the Windows UWP case, as simply reverting the aforementioned changes is probably not the right fix. But from Microsoft documentation (https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/building-for-onecore), OneCore.lib does NOT support UWP. OneCoreUAP.lib should be used instead. |
While reverting the changes in cmake/CMakeLists.txt as detailed in the previous comment produces a working binary UWP binary, it's still lacking DirectML EP support. Adding the --use_dml compile flag yields to broken build with missing delayimp.lib. Here again, I've bisected the problem to commit a300bf2. Reverting the changes in cmake/onnxruntime_providers.cmake and cmake/target_delayload.cmake to keep from
fixes the problem. But since the whole commit was about to remove the WINDOWS_STORE specific code (#10929), I don't know how to deal with this. Other changes in this commit may also be reverted. From my tests, just reverting the aforementioned changes is sufficient. |
With the above changes, I'm able to get a working ONNX Runtime binary, with DirectML EP enabled for ARM64 UWP, for example. One question still remains: is DirectML really working on UWP? Indeed, I'm getting a considerable drop in performances when using DirectML EP rather than just the CPU on HoloLens 2 device, but that's probably the subject to another bug report, unless something in the UWP build presented here is still broken. |
Thanks for pointing the problem out. I'm an ONNX Runtime's developer who manages the cmake files and build scripts. But, sorry I only have very limited knowledge on UWP and OneCore. Below is my understanding of the problem: |
@snnn Thank you for your feedback. I'm not that much familiar with UWP or OneCore either, just a random HoloLens 2 developer, so can't tell if OneCoreUAP is a superset of OneCore or not. However, reading Microsoft's documentation (https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/building-for-onecore) again, it's clearly stated that to support UWP apps, you need to link to OneCoreUAP.lib rather than OneCore.lib:
Regarding the LNK1181 error with missing delayimp.lib, this other Microsoft's documentation (https://learn.microsoft.com/en-us/cpp/build/reference/linker-support-for-delay-loaded-dlls) also clearly states that You can specify which DLLs to delay load by using the /delayload:dllname linker option. If you don't plan to use your own version of a helper function, you must also link your program with delayimp.lib (for desktop applications) or dloadhelper.lib (for UWP apps). Hence the original All this let me believe that UWP apps (or libraries for ONNX Runtime's concern) aren't normal Win32 apps (libraries) and should be dealt in a different manner than plain Win32. Now, how to do this properly at the whole ONNX Runtime codebase scale, I don't know. Maybe @tiagoshibata could give valuable advice? He/she authored several commits w.r.t. Windows/Windows Store in the ONNX Runtime codebase and is probably familiar with all these UWP and OneCore intrinsics. About statically linking to VC runtime, I don't remember the details here, but if I'm not mistaken, dynamic linking was mandatory when enabling the DirectML EP. |
Confirmed: statically linking to VC runtime isn't supported. Adding --enable_msvc_static_runtime flag yields to the following error at configure stage:
|
This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details. |
Describe the issue
Current onnxruntime.dll available in NuGet packages or built from sources fail to build/run on UWP apps. On a HoloLens 2 device for example, onnxruntime.dll incorrectly links to missing dependency MSVCP140[D].dll and VCRUNTIME140[D].dll (this problem was also reported in #4686). Furthermore, adding support for DirectML EP fails to link with missing delayimp.lib import library. I'm reporting these two issues here as I think they both share the same root cause: general Windows UWP support by ONNX Runtime.
Urgency
No response
Target platform
Windows UWP
Build script
build --build_dir build_{arm64|x86|x64}_uwp --config {Debug|Release} --parallel --compile_no_warning_as_error --skip_tests --build_shared_lib [--{arm64|x86}] --cmake_extra_defines CMAKE_SYSTEM_NAME=WindowsStore CMAKE_SYSTEM_VERSION=10.0 CMAKE_SYSTEM_PROCESSOR={aarch64|x86_64|i686} CMAKE_DEBUG_POSTFIX=_d [--use_dml] --path_to_protoc_exe "%ProgramFiles%/protoc-win64/bin/protoc.exe"
Error / output
dumpbin /DEPENDENTS output with missing dependency MSVCP140D.dll and VCRUNTIME140D.dll
onnxruntime_onecore.txt
LNK1181 error with missing delayimp.lib import library
onnxruntime_delayimp.txt
Visual Studio Version
Visual Studio 16 2019
GCC / Compiler Version
No response
The text was updated successfully, but these errors were encountered: