cargo icon indicating copy to clipboard operation
cargo copied to clipboard

On Windows, automatically check `%PATH%` for every DLL required when `cargo run` encounters `exit code: 0xc0000135, STATUS_DLL_NOT_FOUND`

Open docwilco opened this issue 3 years ago • 2 comments

Problem

On Windows, if a DLL is missing, the only information provided is:

error: process didn't exit successfully: `target\debug\foo.exe` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)

AFAIK this is all that Cargo gets back from Windows.

The user then has to manually run dumpbin.exe /dependents target\debug\foo.exe, and (in PowerShell) run Get-Command <DLL name> for every DLL listed, to figure out which is missing from their %PATH%.

Proposed Solution

Upon getting this specific exit code (0xc0000135, STATUS_DLL_NOT_FOUND) it would be absolutely lovely if Cargo would either run dumpbin.exe /dependents (it's part of the MSVS C++ build tools) or snag the DLL list from its own internal data (not sure how easy/difficult that is), and then quickly scan %PATH% for each DLL and tell the user which ones are missing.

Notes

I would be more than happy to try and implement this myself, especially if someone can give a couple of sentences of guidance as to where to snag the data from

docwilco avatar Dec 10 '21 08:12 docwilco

Can you say more about how you ended up in a situation where the path wasn't added to PATH? When using build scripts to link native libraries, they should provide the path to link to, and cargo run will add it to the PATH automatically.

ehuss avatar Jan 17 '22 15:01 ehuss

It would be possible to use the object crate to iterate the import table and gather dll names to look for.

ChrisDenton avatar May 18 '25 14:05 ChrisDenton