没有 IDE 的 Windows 的 C++ 编译器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/958695/
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
C++ Compiler for Windows without IDE?
提问by hahuang65
I'm looking for just a compiler for C++ (such as g++) for Windows, that I could run in my cmd.
我正在寻找适用于 Windows 的 C++(例如 g++)编译器,我可以在我的 cmd 中运行它。
I'm using notepad++ as my text editor and I want to set up a macro in there that can compile my programs for me.
我正在使用记事本++作为我的文本编辑器,我想在其中设置一个可以为我编译程序的宏。
I do not wish to install Cygwin though.
不过我不想安装 Cygwin。
Any suggestions?
有什么建议?
回答by Zifre
MinGW. It's GCC/G++ for Windows. It's much lighter than Cygwin. The main difference from Cygwin GCC is that it doesn't try to emulate UNIX APIs, you have to use the Windows APIs (and of course the standard C/C++ libraries). It also doesn't provide a shell and utilities like Cygwin, just the compiler.
明威。它是适用于 Windows 的 GCC/G++。它比 Cygwin 轻得多。与 Cygwin GCC 的主要区别在于它不尝试模拟 UNIX API,您必须使用 Windows API(当然还有标准的 C/C++ 库)。它也不提供像 Cygwin 这样的 shell 和实用程序,只提供编译器。
There is also a related system called MSYS, which provides a shell, etc. like Cygwin, but this is not required. MinGW itself willrun in CMD (but I highly suggest using something better like Bash, for your own sanity).
还有一个相关的系统叫MSYS,它提供了一个shell等,像Cygwin,但这不是必须的。MinGW 本身将在 CMD 中运行(但我强烈建议使用更好的东西,比如 Bash,为了你自己的理智)。
回答by Greg Hewgill
Visual C++ has a command line compiler, cl
:
Visual C++ 有一个命令行编译器,cl
:
回答by Michael Ratanapintha
If you don't have Visual Studio, you can download the Windows SDK(newer version) or the Windows Driver Kitfor free, and then use the CL.EXE
command-line compiler as suggested by @Greg Hewgill.
如果您没有 Visual Studio,您可以免费下载Windows SDK(较新版本)或Windows 驱动程序工具包,然后CL.EXE
按照@Greg Hewgill 的建议使用命令行编译器。
回答by Joel Lucsy
Digital Marsis excellent.
数字火星很棒。
回答by Gerald
Probably not what you're looking for, but just to add to the question for completeness, the Intel Optimizing Compilerworks great on Windows, Linux and Mac Intel platforms. A bit on the pricey side, but for highly optimized compiles on Intel processors it's second to none.
可能不是您要查找的内容,但只是为了完整性而补充问题,英特尔优化编译器在 Windows、Linux 和 Mac 英特尔平台上运行良好。有点贵,但对于在英特尔处理器上高度优化的编译来说,它是首屈一指的。
回答by Oleg Svechkarenko
回答by binaryfunt
With Windows 10, you can use g++ via the Windows Linux Subsystem.
在 Windows 10 中,您可以通过Windows Linux 子系统使用 g++ 。
Once you've set it up, install g++ using the bash terminal (this answer on Ask Ubuntu shows you how).
设置完成后,使用 bash 终端安装 g++(Ask Ubuntu 上的这个答案向您展示了如何操作)。
Bear in mind: you will only be able to run compiled C++ programs in the Ubuntu/bash environment, not from cmd/PowerShell directly:
请记住:您只能在 Ubuntu/bash 环境中运行已编译的 C++ 程序,而不能直接从 cmd/PowerShell 运行:
C:\Folder> bash
User@Computer:/mnt/c/Folder$ g++ hello_world.cpp -o hello_world
User@Computer:/mnt/c/Folder$ ./hello_world
回答by William Leara
The old Borland C++ non-IDE compiler is freely available:
http://cc.codegear.com/Free.aspx?id=24778
旧的 Borland C++ 非 IDE 编译器可免费获得:http:
//cc.codegear.com/Free.aspx?id=24778
Here is Wikipedia's background on this free, Windows, command-line compiler:
http://en.wikipedia.org/wiki/Borland_C%2B%2B
这是维基百科关于这个免费的 Windows 命令行编译器的背景:http:
//en.wikipedia.org/wiki/Borland_C%2B%2B