Windows CRT, Swift 5.3 & DLL linkage

I have been trying to upgrade to Swift 5.3. When I build something (cross‐compiling out of WSL with SwiftPM), the build succeeds, but when I try to launch the executable (back in Windows), I get this error:

.build/x86_64-unknown-windows-msvc/release/WindowsTests.exe: error while loading shared libraries: api-ms-win-crt-string-l1-1-0.dll: cannot open shared object file: No such file or directory

I am confused for two reasons.

  1. I never saw this error with Swift 5.2, but it was presumably using the DLL too.
  2. I already know the DLL originates from C:\Program Files (x86)\Windows Kits\10\Redist\10.0.19041.0\ucrt\DLLs\x64\api-ms-win-crt-string-l1-1-0.dll, but that hasn’t ended up being much help. I added that to PATH and it still couldn’t be found. Even when I copied it next to the executable (into .build\x86_64-unknown-windows-msvc\release), it still couldn’t be found. Why might the loader seem to be ignoring the standard DLL search patterns?

I’m probably just holding it wrong, but any advice on how to fix it would be appreciated.

@Torust, @compnerd

It is possible that there is some dependent library that is not being loaded. I would suggest you verify if that is the actual failure or not. ProcMon might be helpful here (at least it would be for native windows). I suppose that you can try strace as a stand-in. Something like strace -e open,stat,openat should be pretty helpful.

A lot has changed between 5.2 and 5.3 and between 5.3 and master.

api-ms-win-crt-string-l1-1-0.dll turned out to be a red herring. The real problem was that along with updating, I switched the Swift installation from toolchain.msi + sdk.msi + runtime.msi to just installer.exe, and in doing so, I accidentally removed the piece of the script that registered the runtime folder in PATH. It was actually swiftCore.dll, etc. that couldn’t be found. I restored the PATH entry for /c/Library/Swift-development/bin and everything worked. (I’m not particularly impressed with the error message that send me in the wrong direction for four days, but that is Windows’ fault, not Swift’s.)

Terms of Service

Privacy Policy

Cookie Policy