What is the official way to access the Visual Studio 2019 version of clang from the command prompt?

浪尽此生 提交于 2020-05-13 07:08:14

问题


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

来源:https://stackoverflow.com/questions/59316239/what-is-the-official-way-to-access-the-visual-studio-2019-version-of-clang-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!