10

I am trying to access the Visual Studio 2019 version of clang from the command prompt. I am looking for the official way to do this. So far it doesn't appear to be documented in any of the MSVC/clang blog posts. (Please note that I am not looking for other ways to build/install clang on Windows. This question specifically relates to the VS2019 clang component.)

Using the Visual Studio Installer, I have installed Visual Studio 2019 Professional (version 16.4.1) along with the optional "C++ Clang tools for Windows (9.0.0 - x64/x86)". The clang toolchain appears to be installed at:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\Llvm\bin

(Perhaps I could add this directory to PATH, but this is not robust. Nor could I find this approach documented in any of Microsoft's docs.)

My final goal is to use clang-cl with scons. But as a first step, I would like to be able to run clang-cl from the command prompt.

When I run vcvarsall.bat none of the clang tools are available at the command prompt:

C:\Users\Ross>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.4.1
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Users\Ross>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

C:\Users\Ross>clang
'clang' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Ross>clang++
'clang++' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Ross>clangcl
'clangcl' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Ross>clang-cl
'clang-cl' is not recognized as an internal or external command,
operable program or batch file.

UPDATE 26 February, 2020: Still no satisfactory answer from Microsoft. You can view Microsoft's non-answer and also vote for this issue at: https://developercommunity.visualstudio.com/idea/875419/how-to-use-msvc-installed-c-clang-tools-for-window.html

Ross Bencina
  • 3,822
  • 1
  • 19
  • 33
  • This related question deals with using `clang-cl` with MSBuild but not on the command line: https://stackoverflow.com/q/30761708/2013747 – Ross Bencina Dec 13 '19 at 04:47
  • This related question deals with using an earlier version of `clang-cl` with CMake and Ninja, but doesn't describe how to get `clang-cl` into the PATH https://stackoverflow.com/q/47581784/2013747 – Ross Bencina Dec 13 '19 at 04:49
  • This related question deals with setting up an LLVM build of `clang` to use headers from an earlier version Visual Studio https://stackoverflow.com/q/18711595/2013747 – Ross Bencina Dec 13 '19 at 04:52
  • I have this same problem. – Alex Reinking Feb 26 '20 at 07:11
  • Microsoft's forum is no help: https://developercommunity.visualstudio.com/idea/875419/how-to-use-msvc-installed-c-clang-tools-for-window.html?inRegister=true – Alex Reinking Feb 26 '20 at 07:15

0 Answers0