简体   繁体   English

用于Windows 7的简单“javac”样式命令行C / C ++编译器

[英]A simple “javac” style command-line C/C++ compiler for Windows 7

Over the last couple of months I practiced console programming with Java just with the help of JDK and a text editor of my choice (Notepad++). 在过去的几个月里,我在JDK和我选择的文本编辑器(Notepad ++)的帮助下,使用Java实现了控制台编程。 And I loved the simplicity as a program can be compiled from the command line plainly using javac and run using java . 我喜欢简单,因为程序可以使用javac从命令行javac并使用java运行。

Now, I'm looking for similar compiler for C/C++, such that I create a .c or .cpp file and compile it in the command prompt, and all it does is create a "native" executable that can be run directly from the command prompt. 现在,我正在寻找类似的C / C ++编译器,这样我创建一个.c或.cpp文件并在命令提示符下编译它,它所做的就是创建一个可以直接从中运行的“本机”可执行文件命令提示符。 Thus, without any need of bloated IDE. 因此,无需任何臃肿的IDE。 The reason I'm looking for such simple compiler is because it is going to be used by high-school students so I'm advised to avoid any IDE as far as possible, so students can practice all the concepts of C/C++ languages without having to go for IDE. 我正在寻找这样简单的编译器的原因是因为它将被高中学生使用所以我建议尽量避免使用任何IDE,因此学生可以练习所有C / C ++语言的概念而不用不得不去IDE。 Which compiler can I use that does this job? 我可以使用哪种编译器来完成这项工作? also, I must work across all the versions Windows starting from Windows XP. 另外,我必须在从Windows XP开始的所有Windows版本中工作。

You can download MinGW which is basically GCC for windows. 你可以下载MinGW ,它基本上是GCC for windows。

Then you can simply gcc somefile.c to create an executable. 然后你可以简单地通过gcc somefile.c来创建一个可执行文件。

http://gcc.gnu.org/ gcc是一个多平台的c / c ++编译器

Visual Studio includes the ability to compile from the command line. Visual Studio包括从命令行进行编译的功能。 Like others just said you can look at cygwin/MinGW. 像其他人一样,你可以看看cygwin / MinGW。 I would recommended using Code::Blocks or Dev-C++ . 我建议使用Code :: BlocksDev-C ++ I know you stated you do not want an IDE, but I would highly suggest a minimalist IDE like the ones I just suggested, or at least SciTE or Notepad++ to get some basic syntax highlighting with the ability to configure build tools if you want as well. 我知道你说你不想要一个IDE,但我强烈建议像我刚才建议的那样简单的IDE,或者至少SciTENotepad ++来获得一些基本的语法高亮,能够配置构建工具,如果你想要的话。

MinGW GCC is definitely the way go, but I would recomend the nuwen.net distro ( http://nuwen.net/mingw.html ). MinGW GCC绝对是方式,但我会推荐nuwen.net发行版( http://nuwen.net/mingw.html )。 Haven't used it in a while (yay unix!), but if IIRC, it comes with everything ready to go after unpacking. 有一段时间没有使用它(yay unix!),但是如果是IIRC,那么在打开包装后它就会随时准备好。 The official distribution is ... very hard to get working. 官方发布是......很难开始工作。

A very simple solution woul be cygwin and MinGW , which provides an environment very similar to a UNIX shell. 一个非常简单的解决方案是cygwinMinGW ,它提供了一个非常类似于UNIX shell的环境。 Then you can use the make utilities to compile your program. 然后,您可以使用make实用程序来编译您的程序。

You should certainly consider using MinGW GCC, but not by download from the MiNGW web page, unless you are some kind of masochist. 您当然应该考虑使用MinGW GCC,但不能从MiNGW网页下载,除非您是某种受虐狂。 Get the one packaged by Twilight Dragon Media at http://tdm-gcc.tdragon.net . http://tdm-gcc.tdragon.net上获取由Twilight Dragon Media打包的版本。

I too use VisualStudio on Windows from the command prompt and use VS Make files as well. 我也从命令提示符在Windows上使用VisualStudio,并使用VS Make文件。 That way, I can smb mount my source code from a different machine and perform compiles on several different platforms at once (eg Windows, Linux, Solarsi). 这样,我可以从不同的机器上安装我的源代码并同时在几个不同的平台上执行编译(例如Windows,Linux,Solarsi)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM