Manual install on Windows - missing target libs

Hi,

I installed Rust on my laptop with Windows the manual way (unpack from the archive) as I do not have the administration rights and rustup failed to install.
I set up the PATH to rustc and cargo and I am able to compile with "rustc -L c:\opt\rust-1.87.0-x86_64-pc-windows-gnu\rust-std-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\ main.rs"

But I am not able to run the "cargo build". Cargo is missing the library setup:

cargo build
Downloaded bmp v0.5.0
Downloaded byteorder v1.5.0
Downloaded 2 crates (35.1KiB) in 0.98s
Compiling byteorder v1.5.0
error[E0463]: can't find crate for std
|
= note: the x86_64-pc-windows-gnu target may not be installed

Which environmental variables shall I set for cargo? Thank you.

Did you download the combined tarball (https://static.rust-lang.org/dist/rust-1.88.0-x86_64-pc-windows-gnu.tar.xz)? If so this contains all the various components that form a rust toolchain in separate directories. There is an install script in the root of the archive that combines those directories into a single toolchain. Alternatively you can merge the contents of all the directories inside the main rust-1.87.0-x86_64-pc-windows-gnu directory into a single directory.

Yes, I did it from the tarball. I can see the install script but it is linux-kind. I am not able to run it on Windows.
I believe there must be %CARGO_SOMETHING% variable (or something similar) which points to the libraries in the installation... I tried to set LD_LIBRARY_PATH but it seems unused by cargo...

rustup doesn't need administrator permission to install, can you describe how rustup failed? what's the error message you see?

It failed to install pre-requisities. But to be honest, I did it two weeks ago and started to learn the language. I was happy to run at least rustc with "-L". But today I wanted to import other crates and got stuck with cargo.

try figure out the cause and fix it. for a new learner without any experience, it would be better to stick to rustup.

if you want to go the manual route, you can manually merge all the component directories, e.g., each component has it's own directory containing sub-directories like bin, lib, share, etc, you should move the contents from each component directory into a single directory, i.e. you should end up with a single directory, which contains bin, lib, share, and so on.

try figure out the cause and fix it.

Visual Studio installer requires the admin rights. I do not have it. If I do not install the VC++ prereqs what are the consequences ? Will rust/cargo work ?

VC++ is only required by the *-windows-msvc toolchain, but you can install the toolchain of the *-windows-gnu abi without VC++. e.g. rename the downloaded rustup-init.exe to rustup.exe then run:

$ rustup toolchain install stable-x86_64-pc-windows-gnu

see:

note, the *-windows-gnu toolchain is self-contained with a linker and necessary libraries. however, I recommend to also install msys2/mingw64 so you can use ffi, but it is NOT required for pure rust code. msys2/mingw64 does not require administrator rights to install.

The gnu toolchain is slower to compile and run tests, though. I advise you to ask your admin to install MSVC. Since 2022, it's possible to minimize their interaction to update or modify the VS content, at least (ref).

c:\Users\vaclavpe\Downloads>rustup-init toolchain install stable-x86_64-pc-windows-gnu
error: error: unexpected argument 'toolchain' found
Usage: rustup-init[EXE] [OPTIONS]
For more information, try '--help'.

The parameters seem not working but then I was able to choose the GNU installation option. Now it seems that cargo works properly - it was able to download the external dependencies and compile them.

Thank you for help!