我可以在没有 Visual Studio 的情况下下载 Visual C++ 命令行编译器吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22290501/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 00:01:58  来源:igfitidea点击:

Can I download the Visual C++ Command Line Compiler without Visual Studio?

c++winapivisual-c++

提问by magnus

As per the title. I don't want to download the entire Visual C++ installer, only "cl.exe" and the other programs required for compiling and linking C++ programs on Windows.

按照标题。我不想下载整个 Visual C++ 安装程序,只想下载“cl.exe”以及在 Windows 上编译和链接 C++ 程序所需的其他程序。

采纳答案by Cheers and hth. - Alf

In 2014 you could not download the Visual C++ compiler alone from Microsoft.

2014 年,您无法单独从 Microsoft 下载 Visual C++ 编译器。

It used to be that you could. Then it used to be that you could get it in the Platform SDK. Then you could only get it by installing Visual Studio.

以前是可以的。过去,您可以在 Platform SDK 中获取它。那么你只能通过安装 Visual Studio 来获得它。

Happily, at that time, the compiler that was bundled with Visual Studio Express for Desktop (the free version of Visual Studio at the time) was, and is, the very same that you get with Professional or Universal editions.

令人高兴的是,当时与 Visual Studio Express for Desktop(当时的免费版 Visual Studio)捆绑在一起的编译器与专业版或通用版所获得的编译器完全相同。

In November 2015 Microsoft again started providing the compiler tools in a free-standing package called the Visual C++ Build Tools.

2015 年 11 月,Microsoft 再次开始在名为Visual C++ Build Tools的独立包中提供编译器工具

Microsoft writes:

微软写道:

the C++ Build Tools installer will not run on a machine with Visual Studio 2015 already installed on it. The reverse (i.e. upgrade to Visual Studio) is supported.

C++ Build Tools 安装程序不会在已经安装了 Visual Studio 2015 的机器上运行。支持反向(即升级到 Visual Studio)。

The long term situation is, as always, unclear. And, disclaimer: I have not used the build tools myself – I would have to uninstall Visual Studio first.

长期情况一如既往地不明朗。而且,免责声明:我自己没有使用过构建工具——我必须先卸载 Visual Studio。

回答by alecov

As said, there is no way to do that. You need to download the entire 4-6GB+ bundle. MS deployment is a botch.

如上所述,没有办法做到这一点。您需要下载整个 4-6GB+ 包。MS 部署是一个烂摊子。

There is no need, however, to actually installeverything. If you're up to some manual installation, you can extract individual components from the bundle and put them all in a more organized directory tree.

然而,没有必要实际安装所有东西。如果您需要进行一些手动安装,您可以从捆绑包中提取单个组件并将它们全部放在一个更有条理的目录树中。

For example, I've found the following set to be the bare minimum needed for using the current MSVC2013 compilers in a x86 environment:

例如,我发现以下设置是在 x86 环境中使用当前 MSVC2013 编译器所需的最低要求:

  • vc_compilerCore86.msi: MSVC toolchain;
  • vc_compilerCore86res.msi: MSVC toolchain MUI resources;
  • vc_librarycore86.msi: MSVC library stuff;
  • vc_LibraryDesktopX86.msi: More MSVC library stuff;
  • Windows Software Development Kit for Windows Store Apps-x86_en-us.msi: Windows SDK files and related tools (rc.exe, mt.exe, etc.);
  • Windows Software Development Kit-x86_en-us.msi: More Windows SDK files (specifically, WinSock2.h, WS2_32.lib, maybe others).
  • vc_compilerCore86.msi:MSVC 工具链;
  • vc_compilerCore86res.msi:MSVC 工具链 MUI 资源;
  • vc_librarycore86.msi:MSVC 库的东西;
  • vc_LibraryDesktopX86.msi:更多 MSVC 库的东西;
  • Windows Software Development Kit for Windows Store Apps-x86_en-us.msi:Windows SDK的文件和相关的工具(rc.exemt.exe,等);
  • Windows Software Development Kit-x86_en-us.msi:更多 Windows SDK 文件(特别是WinSock2.hWS2_32.lib、 可能还有其他文件)。

Remember that you can extract the contents of a MSI file by running msiexec /a <msifile> TARGETDIR="<path>"(jot a /quietparameter if you're batching). Of course, you can also put more into your package by investigating the MSI files inside the bundle. In particular, the above set is missing the latest MSBuild tools, since I don't care for them. Stuff is often scattered around between multiple MSIs cluelessly, so good luck.

请记住,您可以通过运行来提取 MSI 文件的内容msiexec /a <msifile> TARGETDIR="<path>"/quiet如果您正在批处理,请记下一个参数)。当然,您也可以通过调查包中的 MSI 文件将更多内容放入包中。特别是,上面的集合缺少最新的 MSBuild 工具,因为我不关心它们。东西经常散落在多个 MSI 之间,毫无头绪,所以祝你好运。

I've got a 50MB (!!!) 7z-file containing this set for local deployment, though I cannot share this publicly due to Microsoft licensing restrictions.

我有一个 50MB (!!!) 7z 文件,其中包含用于本地部署的此集,但由于 Microsoft 许可限制,我无法公开共享此文件。



UPDATE:

更新:

This is the list of MSI files for MSVC2015 tools, headers and libraries:

这是 MSVC2015 工具、头文件和库的 MSI 文件列表:

packages\VisualC_D14\VC_Tools.Core\VC_Tools.Core.msi
packages\VisualC_D14\VC_Tools.Core.Res\VC_Tools.Core.Res.msi
packages\VisualC_D14\VC_Tools.X86.Base\VC_Tools.X86.Base.msi
packages\VisualC_D14\VC_Tools.X86.Base.Res\VC_Tools.X86.Base.Res.msi
packages\VisualC_D14\VC_Tools.X86.Nat\VC_Tools.X86.Nat.msi
packages\VisualC_D14\VC_Tools.X86.Nat.Res\VC_Tools.X86.Nat.Res.msi
packages\VisualC_D14\VC_Tools.X86.X64\VC_Tools.X86.X64.msi
packages\VisualC_D14\VC_Tools.X86.X64.Res\VC_Tools.X86.X64.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Base\VC_PremTools.X86.Base.msi
packages\VisualC_D14\VC_PremTools.X86.Base.Res\VC_PremTools.X86.Base.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Nat\VC_PremTools.X86.Nat.msi
packages\VisualC_D14\VC_PremTools.X86.Nat.Res\VC_PremTools.X86.Nat.Res.msi
packages\VisualC_D14\VC_PremTools.X86.X64\VC_PremTools.X86.X64.msi
packages\VisualC_D14\VC_PremTools.X86.X64.Res\VC_PremTools.X86.X64.Res.msi
packages\VisualC_D14\VC_CRT.Headers\VC_CRT.Headers.msi
packages\VisualC_D14\VC_CRT.X86.Desktop\VC_CRT.X86.Desktop.msi
packages\VisualC_D14\VC_CRT.X86.Store\VC_CRT.X86.Store.msi
packages\VisualC_D14\VC_CRT.X64.Desktop\VC_CRT.X64.Desktop.msi
packages\VisualC_D14\VC_CRT.X64.Store\VC_CRT.X64.Store.msi
packages\VisualC_D14\VC_CRT.Redist.Res\VC_CRT.Redist.Res.msi
packages\VisualC_D14\VC_CRT.Redist.X86\VC_CRT.Redist.X86.msi
packages\VisualC_D14\VC_CRT.Redist.X64\VC_CRT.Redist.X64.msi
packages\VisualC_D14\VC_ATL.Headers\VC_ATL.Headers.msi
packages\VisualC_D14\VC_ATL.X86\VC_ATL.X86.msi
packages\VisualC_D14\VC_ATL.X64\VC_ATL.X64.msi
packages\VisualC_D14\VC_MFC.Headers\VC_MFC.Headers.msi
packages\VisualC_D14\VC_MFC.X86\VC_MFC.X86.msi
packages\VisualC_D14\VC_MFC.X64\VC_MFC.X64.msi
packages\VisualC_D14\VC_PGO.Headers\VC_PGO.Headers.msi
packages\VisualC_D14\VC_PGO.X86\VC_PGO.X86.msi
packages\VisualC_D14\VC_PGO.X64\VC_PGO.X64.msi
packages\Win10_UniversalCRTSDK\Universal CRT Headers Libraries and Sources-x86_en-us.msi

And this is the list of MSI files for WinSDK10 tools, headers and libraries (downloaded separately):

这是 WinSDK10 工具、头文件和库的 MSI 文件列表(单独下载):

Installers\Windows SDK Desktop Headers Libs Metadata-x86_en-us.msi
Installers\Windows SDK Desktop Tools-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Headers Libs-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Tools-x86_en-us.msi

All of this include stuff for both x86and x64(I haven't considered ARM or IA64). Both bundles compressed with LZMA will yield a 185MB file.

所有这些都包括x86x64(我没有考虑过 ARM 或 IA64)的东西。用 LZMA 压缩的两个包都会产生一个 185MB 的文件。

回答by apardoe

Update: The Visual C++ 2015 Build Tools are located here: http://landinghub.visualstudio.com/visual-cpp-build-tools

更新:Visual C++ 2015 构建工具位于此处:http: //landinghub.visualstudio.com/visual-cpp-build-tools

The Visual C++ 2017 Build Tools are now part of the regular VS 2017 installer. Just select the workloads you need. Information is on the same page.

Visual C++ 2017 Build Tools 现在是常规 VS 2017 安装程序的一部分。只需选择您需要的工作负载。信息在同一页上。

This link is preferred to the blog links below as it's the official landing page and will be kept up-to-date.

此链接比下面的博客链接更受欢迎,因为它是官方登录页面,并且会保持最新状态。

I'm on the C++ team. If you have any questions about using the VC++ Build Tools or about MSVC in general, feel free to email me. My email is my StackOverflow user name @microsoft.com.

我在 C++ 团队。如果您对使用 VC++ 构建工具或一般 MSVC 有任何疑问,请随时给我发电子邮件。我的电子邮件是我的 StackOverflow 用户名 @microsoft.com。

回答by GreenhouseVeg

I ended up using Chocolatey, which has a package for Visual C++ Build Tools.

我最终使用了Chocolatey,它有一个Visual C++ Build Tools 包

This command:

这个命令:

choco install visualcpp-build-tools 

will install the latest 2017 version, but you can select one of the older versions, which include the 2015 release.

将安装最新的 2017 版本,但您可以选择旧版本之一,其中包括 2015 版本。

After the installation Visual Studio 2017folder is added to the Programsmenu. It includes shortcuts to various developer command prompts with cl.exeand other tools in the path.

安装后Visual Studio 2017文件夹被添加到程序菜单中。它包括路径中带有cl.exe和其他工具的各种开发人员命令提示的快捷方式。

回答by Nayana Adassuriya

Once I tried to do same this as you. But MS doesn't provide isolated compiler. So if you need MS C++ compiler you must need to install the VS. But if you like to adventure. there is a tricky way to do that. Try it here. Chrees!

有一次我试图和你做同样的事情。但是 MS 不提供隔离的编译器。因此,如果您需要 MS C++ 编译器,则必须安装 VS。但如果你喜欢冒险。有一种棘手的方法可以做到这一点。在这里试试。克里斯!

回答by jaho

You can use MSVC compiler without Visual Studio and the latest version is available here:

您可以在没有 Visual Studio 的情况下使用 MSVC 编译器,最新版本可在此处获得:

http://www.microsoft.com/en-us/download/details.aspx?id=41151

http://www.microsoft.com/en-us/download/details.aspx?id=41151

Also here's a website which details the command line options for the compiler:

这里还有一个网站,其中详细介绍了编译器的命令行选项:

http://msdn.microsoft.com/en-us/library/9s7c9wdw.aspx

http://msdn.microsoft.com/en-us/library/9s7c9wdw.aspx

回答by Patrick

As of 2019 Microsoft offers Visual Studio Build Toolswhich only includes the compiler, build tools and SDK. It's hidden in the all downloads list.

截至 2019 年,Microsoft 提供Visual Studio 构建工具,其中仅包括编译器、构建工具和 SDK。它隐藏在所有下载列表中。