Diesel is an ORM framework in Rust, but maybe you will got the these errors like belowing when you use diesel_cli first time:

Missing DLLs

error while loading shared libraries: api-ms-win-crt-locale-l1-1-0.dll: cannot open shared object file: No such file or directory

The error above will appear on shell bash, while using PowerShell will show nothing.

Obviously we are missing some DLL files, like api-ms-win-crt-locale-l1-1-0.dll, etc.

However, the files that diesel requires can be found in the directory C:\Windows\System32 or C:\Windows\SysWOW64, so you can copy those files from System32 to ~/.cargo/bin

You might need to copy these files:

  • api-ms-win-crt-heap-l1-1-0.dll
  • api-ms-win-crt-locale-l1-1-0.dll
  • api-ms-win-crt-math-l1-1-0.dll
  • api-ms-win-crt-runtime-l1-1-0.dll
  • api-ms-win-crt-stdio-l1-1-0.dll
  • api-ms-win-crt-string-l1-1-0.dll

Just Copy and paste them.

And if use diesel with sqlite, diesel might show up you lose sqlite3.dll, and this file not exist at System32 or SystemWOW64, well you can download it from this link: https://www.sqlite.org/2024/sqlite-dll-win-x64-3450300.zip, after downloading, unzip it and you will find sqlite3.lib. Put it in ~/.cargo/bin.

Then it will works well!

Missing sqlite3.lib

I got this error when I operate sqlite file with diesel:

error: linking with `link.exe` failed: exit code: 1181
...
... elision
...
= note: LINK : fatal error LNK1181: cannot open input file “sqlite3.lib”
error: could not compile `diesel_cli` (bin "diesel") due to previous error
error: failed to compile `diesel_cli v2.1.1`, intermediate artifacts can be found at `C:\Users\dvora\AppData\Local\Temp\cargo-installgPS6WL`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

That's because the diesel cannot find the file sqlite3.lib at the path ~/.rustup/toolchains/.....

Where can I get sqlite3.lib?

well you can download it from this link: https://www.sqlite.org/2024/sqlite-dll-win-x64-3450300.zip, after downloading, unzip it and you will find sqlite3.dll, into that directory.

Open the developer Command Prompt for VS 2022, copy paste this command and press enter: lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64

And you will see sqlite3.lib outputed.

Move sqlite3.lib to the path ~/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc/lib/,

Note the part of the path: stable-x86_64-pc-windows-msvc, that's because my version of Rust is stable,

you should change this part if you use nightly, it might be: nightly-x86_64-pc-windows-msvc