Windows support is highly experimental. Known issues are marked with label “Windows” on github issues.
We currently support only 64 bit Windows 7 or higher and we compile Bazel as a msys2 binary.
Release binaries are available on our GitHub release page.
To run the binary you will need:
C:\tools\msys64\
).Before you run the binary, you will need to set some environment variables:
export JAVA_HOME="$(ls -d C:/Program\ Files/Java/jdk* | sort | tail -n 1)" export BAZEL_SH=c:/tools/msys64/usr/bin/bash.exe
If you run outside of bash
, ensure that msys-2.0.dll
is in your PATH
(if you install msys2 to c:\tools\msys64
, just add c:\tools\msys64\usr\bin
to PATH
).
To bootstrap Bazel on Windows, you will need:
C:\tools\msys64\
).pacman
command to install them: pacman -Syuu gcc git curl zip unzip zlib-devel
To build Bazel:
export JAVA_HOME="$(ls -d C:/Program\ Files/Java/jdk* | sort | tail -n 1)" export BAZEL_SH=c:/tools/msys64/usr/bin/bash.exe
Run ``compile.sh`` in Bazel directory.
If all works fine, bazel will be built at ``output\bazel.exe``.
Bazel now supports building C++, Java and Python targets on Windows.
To build C++ targets, you will need:
Visual Studio
We are using MSVC as the native C++ toolchain, so please ensure you have Visual Studio installed with the Visual C++ components (which is NOT the default installation type of Visual Studio). You can set BAZEL_VS environment variable to tell Bazel where Visual Studio is, otherwise Bazel will try to find the latest version installed.
For example: export BAZEL_VS="C:/Program Files (x86)/Microsoft Visual Studio 14.0"
Python 2.7
Currently, we use python wrapper scripts to call the actual MSVC compiler, so please make sure Python is installed and its location is added into PATH. It's also a good idea to set BAZEL_PYTHON environment variable to tell Bazel where python is.
For example: export BAZEL_PYTHON=C:/Python27/python.exe
Bazel will auto-configure the location of Visual Studio and Python at the first time you build any target. If you need to auto-configure again, just run bazel clean
then build a target.
If everything is set up, you can build C++ target now! However, since MSVC toolchain is not default on Windows yet, you should use flag --cpu=x64_windows_msvc
to enable it like this:
$ bazel build --cpu=x64_windows_msvc examples/cpp:hello-world $ ./bazel-bin/examples/cpp/hello-world.exe $ bazel run --cpu=x64_windows_msvc examples/cpp:hello-world
Building Java targets works well on Windows, no special configuration is needed. Just try:
$ bazel build examples/java-native/src/main/java/com/example/myproject:hello-world $ ./bazel-bin/examples/java-native/src/main/java/com/example/myproject/hello-world $ bazel run examples/java-native/src/main/java/com/example/myproject:hello-world
On Windows, we build a self-extracting zip file for executable python targets, you can even use python ./bazel-bin/path/to/target
to run it in native Windows command line (cmd.exe). See more details in this design doc.
$ bazel build examples/py_native:bin $ ./bazel-bin/examples/py_native/bin $ python ./bazel-bin/examples/py_native/bin # This works in both msys and cmd.exe $ bazel run examples/py_native:bin