Reputation: 362
I`m working myself through a Tensorflow installation session (each one is a unique experience) and I'm trying to understand what is going wrong with the Bazel build tool.
For that, I have followed the example here after downloading everything mentioned in the guide. I also added the environment variable appropriately:
After trying to build an example I get:
The target you are compiling requires Visual C++ build tools.
Bazel couldn't find a valid Visual C++ build tools installation on your machine.
Visual C++ build tools seems to be installed at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC
But Bazel can't find the following tools:
VCVARSALL.BAT, cl.exe, link.exe, lib.exe, ml64.exe
which does not make sense. I checked that cl.exe, link.exe and ml64.exe can be found in this directory. My another suspicion was that I might need administrator rights, so I did run the build with admin rights too, but it did not make a difference.
My suspicion is that the VCVARSALL.bat might be missing, but I dont know what I would need to install to get that file.
Upvotes: 4
Views: 7413
Reputation: 1
Just write these commands in your bash (do changes according to you) and it will be solved
export BAZEL_VC="/c/Program Files/Microsoft Visual Studio/2022/Community/VC"
export BAZEL_VS="/c/Program Files/Microsoft Visual Studio/2022/Community"
export PATH="$BAZEL_VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64:$PATH"
export PATH="$BAZEL_VS/VC/Auxiliary/Build:$PATH"
Upvotes: 0
Reputation: 1
In Windows 11, with VS 22 ( Community Edition) installed, we can get bazel to work by renaming C:\Program Files (x86)\Microsoft Visual Studio\2022
to C:\Program Files (x86)\Microsoft Visual Studio\2017
.
Here's the best way to create a link:
mklink /D "C:\Program Files (x86)\Microsoft Visual Studio\2017" "C:\Program Files (x86)\Microsoft Visual Studio\2022"
Upvotes: 0
Reputation: 11
I have 2 Win 10 Pro machines (one Domain joined and one standalone on both I am local Admin), both with VS 2022 Beta 17.6 identical install and same SDKs. On one I can build without issue and on the other I keep getting the "Bazel couldn't find a valid Visual C++ build tools installation on your machine." with all the BAZEL_VC and VS vars set accordingly. The only difference is that on the non working machine I also have VS 2010 which I need to keep for other purposes. However even when setting the BAZEL_VC and VS (the latter one can suffice actually as the VC path is derived from VS in the Bazel search) it still reports not finding any VC++ build tools. Seems like some bug in bazel caused by my existing VS 10 install, or possibly some other culprit. P.S. Bazel is v5.2.0 My env Vars:
BAZEL_SH=C:\msys64\usr\bin\bash.exe
BAZEL_VC=C:\Program Files\Microsoft Visual Studio\2022\Preview\VC
BAZEL_VC_FULL_VERSION=14.36.32502
BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Preview
BAZEL_WINSDK_FULL_VERSION=10.0.20348.0
Upvotes: 0
Reputation: 183
Had the similar issue with Visual Studio 2022:
The target you are compiling requires Visual C++ build tools.
Bazel couldn't find a valid Visual C++ build tools installation on your machine.
Visual C++ build tools seems to be installed at C:\Program Files\Microsoft Visual Studio\2022\Community\VC
But Bazel can't find the following tools:
VCVARSALL.BAT, cl.exe, link.exe, lib.exe, ml64.exe
for x64 target architecture
Issue has been solved after upgrading Bazel 4.4.4 to 5.2.0
Upvotes: 0
Reputation: 530
I had this problem too, so the follwoing steps solved my problem:
Upvotes: 1
Reputation: 71
Go to Start Menu > Settings.
Find the setting “Edit environment variables for your account”
Look at the list on the top (“User variables for ”), and click the “New…” button below it.
For “Variable name”, enter BAZEL_VC
Click “Browse Directory…”
Navigate to the VC directory of Visual Studio.
For example, this might be C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC on your system.
Select the VC folder and click OK
The “Variable value” field now has the path to VC. Click OK to close the window.
Done.
If you open a new cmd.exe or PowerShell terminal and run Bazel now, it will find Visual C++.
您好,这个是官网的连接https://docs.bazel.build/versions/main/install-windows.html
好像就是说 set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC 这两行代码没有效果,虽然运行没有错误,但是并没有起到效果 还是要用原始的方法,在我的电脑里面->高级系统设置->环境变量->用户变量;自己手动创建BAZEL_VS和BAZEL_VC这两个变量
Upvotes: 6
Reputation: 362
Okay, so the problem could be solved by renaming the Visual Studio directory to 2017, due to the fact that the 0.24.1 version of the Bazel I`m using does not seem to work with the toolchain layout of the 2019 version of the Build Tools.
More can be found about reading this github issue. Naturally, the corresponding environment variables has to be also changed. Another (better) solution would probably be to use the 2017 install of the Build Tools or a more recent version of the Bazel, but this is the one that is recommended in TFs current installation guide.
Upvotes: 0