https://github.com/nathan818fr/vcvars-bash
Use the Microsoft C++ toolset from Bash (vcvarsall.bat -> vcvarsall.sh)
https://github.com/nathan818fr/vcvars-bash
gitbash msvc msys2 vcvars vcvarsall wsl
Last synced: about 1 month ago
JSON representation
Use the Microsoft C++ toolset from Bash (vcvarsall.bat -> vcvarsall.sh)
- Host: GitHub
- URL: https://github.com/nathan818fr/vcvars-bash
- Owner: nathan818fr
- License: mit
- Created: 2023-11-27T06:38:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-09T12:24:36.000Z (8 months ago)
- Last Synced: 2025-10-12T05:52:59.298Z (5 months ago)
- Topics: gitbash, msvc, msys2, vcvars, vcvarsall, wsl
- Language: Shell
- Homepage:
- Size: 13.7 KB
- Stars: 32
- Watchers: 2
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vcvars-bash
Use the Microsoft C++ toolset from Bash!
## vcvarsall.sh
This script load MSVC environment variables using `vcvarsall.bat` and exports
them.
It is intended to be evaluated (by Bash or any other POSIX-compatible shell,
since it writes a list of export commands to stdout).
Usage: `eval "$(vcvarsall.sh [vcvarsall.bat arguments])"`
See [Microsoft vcvarsall.bat syntax][1] for vcvarsall.bat arguments
documentation.
Example:
```bash
eval "$(./vcvarsall.sh x64)"
cmake -S .. -B build -G "NMake Makefiles"
cmake --build build --config Release
```
## vcvarsrun.sh
Like `vcvarsall.sh`, but runs a command instead of exporting variables.
Usage: `vcvarsrun.sh [vcvarsall.bat arguments] -- command [arguments...]`
Example:
```bash
./vcvarsrun.sh x64 -- cl /nologo /EHsc /Fe:hello.exe hello.cpp
./vcvarsrun.sh x64 -- ./my_build_script.sh
```
## Compatibility
These scripts are designed to run on Windows with Bash.
They work with:
- Git Bash
- WSL
- MSYS2
- Cygwin
## Configuration (optional)
To work, these scripts must locate `vcvarsall.bat`.\
By default, it uses `vswhere.exe` (installed with Visual Studio) to
automatically find the latest Visual Studio installation.\
You can override this behavior by setting the `VSINSTALLDIR` environment
variable (e.g.
`VSINSTALLDIR='C:\Program Files\Microsoft Visual Studio\2022\Community'`).
[1]: https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#vcvarsall-syntax