C语言 如何在没有 Visual Studio 的情况下下载和安装 Microsoft 的 Visual Studio C/C++ 编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49089448/
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-09-02 10:44:19  来源:igfitidea点击:

How to download and install Microsoft's Visual Studio C/C++ compiler without Visual Studio

cvisual-studio

提问by Huzaifa Hussain

I'm trying to run c code on my windows. (I had been running it so far on repl.it). But it is proving harder than it is supposed to be. MinGW is not installing due to some reason. And I've spent a lot of time trying to run it some other way. From my research, I think the best way to go about it is to download Visual Studio, but I have a low-end PC and I don't think I shouldinstall Visual Studio. Can I, somehow, only install the C/C++ compiler that comes with it without installing Visual Studio itself.

我正在尝试在我的 Windows 上运行 c 代码。(到目前为止,我一直在 repl.it 上运行它)。但事实证明,这比预期的要困难。由于某种原因,MinGW 没有安装。我花了很多时间尝试以其他方式运行它。根据我的研究,我认为最好的方法是下载 Visual Studio,但我有一台低端 PC,我认为我不应该安装 Visual Studio。我可以以某种方式只安装它附带的 C/C++ 编译器而不安装 Visual Studio 本身。

If it helps, I usually run my (python) code in atom, but also have Visual Studio Code installed on my machine.

如果有帮助,我通常会在 atom 中运行我的(python)代码,但也会在我的机器上安装 Visual Studio Code。

I apologize if my question is stupid, I am a self-taught programmer who learned to code from MIT's 6.00.1x and 6.00.2x and am currently trying to learn C from 'The C Programming Language' by Kernighan and Ritchie. I've never formally studied computer science.

如果我的问题很愚蠢,我深表歉意,我是一名自学成才的程序员,他从 MIT 的 6.00.1x 和 6.00.2x 学习编码,目前正在尝试从 Kernighan 和 Ritchie 的“C 编程语言”中学习 C。我从未正式学习过计算机科学。

回答by Andreas Grapentin

What you want is called the "Windows SDK", wich contains everything you need to build applications on windows, except the IDE (Visual Studio).

您想要的是“Windows SDK”,其中包含在 Windows 上构建应用程序所需的一切,但 IDE (Visual Studio) 除外。

It comes with all necessary libraries, header files, a compiler, nmake et cetera, and a handy shortcut for a preconfigured cmd.exethat puts all of these tools in your PATH. If you know what you are doing, this is what you want to use.

它带有所有必需的库、头文件、编译器、nmake 等,以及一个方便的预配置快捷方式cmd.exe,可将所有这些工具放入您的PATH. 如果你知道你在做什么,这就是你想要使用的。

What version of the SDK you want depends on the system you are compiling on, but you will find all of them on the microsoft website. For windows 10 for example, the SDK can be found here: https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk

您想要的 SDK 版本取决于您编译的系统,但您可以在微软网站上找到所有版本。例如,对于 Windows 10,可以在此处找到 SDK:https: //developer.microsoft.com/en-US/windows/downloads/windows-10-sdk

Be aware though, that the windows compiler cl.execan be a bit tricky at times, and nmake is not what you expect when you only learned GNUmake. If you are only starting out learning C, then I would not recommend using the SDK for the reasons given in the comments to your question. However, if all you want is compile on windows, without having to drag 20+ Gigabytes of IDE around, then the SDK is an option to consider.

但请注意,Windows 编译器cl.exe有时会有点棘手,当您只学习 GNUmake 时,nmake 并不是您所期望的。如果您只是刚开始学习 C,那么出于对您的问题的评论中给出的原因,我不建议使用 SDK。但是,如果您想要的只是在 Windows 上编译,而不必拖着 20+ GB 的 IDE,那么 SDK 是一个可以考虑的选项。

(We are using virtual machines with a preinstalled windows SDK quite successfully in lectures and exercises.)

(我们在讲座和练习中非常成功地使用了预装了 Windows SDK 的虚拟机。)

UPDATE:

更新:

I have been made aware that as of windows 8 the SDK no longer contains the build tools for C++ based applications. These are now only contained in a Visual Studio installation.

我已经意识到,从 Windows 8 开始,SDK 不再包含用于基于 C++ 的应用程序的构建工具。这些现在仅包含在 Visual Studio 安装中。

回答by Joe

You can download the compiler and related stuff as part of the Visual Studio Build Tools. The 2017 version is here:

您可以下载编译器和相关内容作为 Visual Studio 构建工具的一部分。2017 版本在这里:

https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017

https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017