crates-build-env
crates-build-env copied to clipboard
Put `cl.exe` and `link.exe` on `PATH` on Windows?
The vast majority of crates use the cc crate for building native libraries. However, a few want the compiler and/or linker on the PATH (see https://github.com/blt/mond). This seems pretty standard coming from the UNIX world, but the normal workflow on Windows seems to be sourcing a vcvars.bat file before you build something. I'm not sure if this should be the crate's responsibility or ours. This is complicated by the fact that powershell doesn't have a source equivalent, so one has to do a contrived workaround to permanently save the configuration in vcvars.bat.
The github repo timvisee.cant-touch-this is a good test case for this. It uses the cmake crate to build a dependency and fails with:
couldn't determine visual studio generator
if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate
Note that with VS 2019 you could also try to use Developer PowerShell although it seems that's only available for x86 toolset.