简体   繁体   English

用于Windows的简单C ++编译器

[英]Simple C++ compiler for windows

Thought I'd write something in C++ instead of some interpreted languages (cause I need the performance for something simple) and went around trying different tools. 我以为我会用C ++而不是一些解释性的语言写一些东西(因为我需要简单的表现)然后去尝试不同的工具。

First I found cygwin cause it had g++, but it requires cygwin.dll to run the exe's. 首先我发现cygwin因为它有g ++,但它需要cygwin.dll来运行exe。

Then I tried mingw, but it seems like I need to include some dll's with the distribution like libgcc and libgstd or something, which bloats the executable to about a MB (I don't really need that many bytes to do simple file I/O) 然后我尝试了mingw,但似乎我需要在libgcc和libgstd之类的内容中包含一些dll,这会使可执行文件膨胀到大约MB(我真的不需要那么多字节来做简单文件I / O )

Then I looked at Visual C++ 2010 since I already had it installed, but it looks like I need to install 2008 just to use .net framework 3.5. 然后我查看了Visual C ++ 2010,因为我已经安装了它,但看起来我需要安装2008只是为了使用.net framework 3.5。 Well, I wouldn't mind using 4.0, but I imagine there are many people that don't have 4.0 on their windows machines and it would be quite an inconvenience to read a file. 好吧,我不介意使用4.0,但我想有很多人在他们的Windows机器上没有4.0,读取文件会很不方便。

What can I use that will allow me to pass around small exe's (eg: a few KB's worth) that perform simple one-off things that will run on most windows machines? 我可以使用什么来让我传递小exe(例如:几KB的价值)来执行在大多数Windows机器上运行的简单的一次性操作? (since it is only relevant to windows users) (因为它只与windows用户有关)

Or should I just use C and go with gcc for mingw? 或者我应该只使用C并使用gcc进行mingw?

At least some of the obvious candidates: 至少有一些明显的候选人:

VC++: As of VC++ 2010 is starting to support some C++11 features. VC ++:从VC ++开始,2010年开始支持一些C ++ 11特性。 VC++11 (currently in beta testing) adds a few more. VC ++ 11(目前处于beta测试阶段)增加了一些。 Has pretty decent code generation, a debugger quite a few people think is the best you can get, and an IDE that produces rather mixed reviews. 有相当不错的代码生成,很多人认为是最好的调试器,以及一个产生相当混合的评论的IDE。 Many who've used them consider older generations of the IDE (VC++5 and 6) better in at least some ways, but the compiler has improved so much since then that the older IDEs really aren't an option for most people (except to support ancient code). 许多使用它们的人至少在某些方面更好地考虑了老一代的IDE(VC ++ 5和6),但是从那时起编译器已经有了很大的改进,以至于旧的IDE确实不适合大多数人(除了支持古代代码)。

MinGW: STL's current package features gcc 4.7.0, which (at least arguably) has somewhat better C++11 support than VC++. MinGW:STL目前的软件包具有gcc 4.7.0,它(至少可以说是)比VC ++有更好的C ++ 11支持。 It includes quite a few ported Unix/Linux tools, but is basically a command line-only environment. 它包含了很多移植的Unix / Linux工具,但基本上只是一个命令行环境。 If you want something like an IDE, you'll have to install/configure it separately. 如果您想要类似IDE的东西,则必须单独安装/配置它。

Cygwin: This is also based on gcc, but instead of porting the compiler to Windows, they ported Linux to Windows, and run the compiler on the ported Linux. Cygwin:这也是基于gcc,但不是将编译器移植到Windows,而是将Linux移植到Windows,并在移植的Linux上运行编译器。 Obviously I'm exaggerating (a little) but not a whole lot -- Cygwin is mostly to run Linux/Unix code on Windows with as few alterations as possible. 显然我夸大了(一点点)但不是很多--Cygwin主要是在Windows上运行Linux / Unix代码,尽可能少的改动。 The tools they ship fit that as well -- it's doing its best to be a Unix-like environment that runs under the Windows kernel. 他们提供的工具也适合 - 它正在尽力成为在Windows内核下运行的类Unix环境。 It definitely would not be my first choice for any new development. 对于任何新的开发来说,它绝对不是我的首选。

Qt Creator/SDK: this is another packaging of gcc, but with an IDE. Qt Creator / SDK:这是gcc的另一个包装,但是带有IDE。 If you want to write code using Qt it might well be your first choice. 如果你想用Qt编写代码,它可能是你的第一选择。 Otherwise, I'd probably avoid it -- while it probably can work fine otherwise, it's written assuming Qt as the default. 否则,我可能会避免它 - 虽然它可能可以正常工作,否则,它是假设Qt为默认值。

Eclipse/CDT: You can find this packaged with a copy of g++ as well. Eclipse / CDT:您也可以使用g ++的副本找到它。 At least the last time I tried, it needed quite a bit of work on the configuration before I could even get it to compile correctly. 至少在我最后一次尝试时,它需要相当多的配置工作才能让它正确编译。 If you use Eclipse for other purposes, getting it to do C++ is probably worthwhile. 如果你将Eclipse用于其他目的,那么让它做C ++可能是值得的。 Otherwise, I'd personally avoid it. 否则,我个人会避免它。

C++ Builder: In the Borland days, this was the biggest challenger to Microsoft's dominance. C ++ Builder:在Borland时代,这是微软主导地位的最大挑战者。 Embarcadero seems to be trying to get it back in the mainstream again. Embarcadero似乎试图让它再次回归主流。 The emphasis here seems to be much more on the IDE, GUI toolkit, etc., than the compiler proper. 这里的重点似乎更多地放在IDE,GUI工具包等上,而不是编译器本身。 The compiler itself seems to be somewhat behind gcc and/or VC++. 编译器本身似乎有点落后于gcc和/或VC ++。 The starter edition costs $150, and limits sales of output to $1000, at which point you need to spend most of your $1000 on an upgrade to the Professional edition. 入门版售价150美元,并将产量销售限制在1000美元,此时您需要花费1000美元的大部分资金升级到专业版。

Clang: The most recently started of the major compilers, but really working at being one of the best. Clang:最近开始的主要编译器,但真正努力成为最好的编译器之一。 Has some of the best diagnostics of any compiler available. 拥有任何可用编译器的最佳诊断功能。 Targets LLVM, which gives it quite a variety of tools for run-time analysis and such. 目标LLVM,它为运行时分析提供了各种各样的工具。 Its major corporate sponsor is Apple, though, so while it runs nicely out of the box on OS/X (and is now the default compiler there) on Windows, you're a lot more on your own -- AFAIK, you need some other compiler installed and working (and really know how to use it) to get this to install at all. 它的主要企业赞助商是苹果,虽然如此,而它运行了很好的在Windows上的OS / X(现在是默认的编译器有)的方块,你多了很多对自己的-据我所知,你需要一些安装和工作的其他编译器(并且真正知道如何使用它)来安装它。 On Windows, this a bit like buying a muscle car from a junk yard. 在Windows上,这有点像从垃圾场买一辆肌肉车。 With enough work, you may end up with the coolest car in town -- but on Windows it's currently more a project than a tool. 有了足够的工作,你可能会得到镇上最酷的汽车 - 但在Windows上,它目前更像是一个项目而不是一个工具。

A few more to generally avoid: 还有一些通常可以避免:

  1. Any version of VC++ before about 2008. Simply inferior implementation of C++. 大约在2008年之前的任何版本的VC ++。简单的低级C ++实现。
  2. Any version of g++ before 4.x. 4.x之前的任何g ++版本。 Again, inferior implementation of C++. 再次,C ++的劣质实现。
  3. djgpp: pretty much the worst of the worst. djgpp:几乎是最糟糕的。 This really targets MS-DOS with a (custom) DOS extender. 这真的针对MS-DOS与(自定义)DOS扩展器。 An ancient version of gcc rounds out the awfulness. 一个古老版本的gcc完善了可怕性。
  4. OpenWatcom: also primarily targets MS-DOS. OpenWatcom:也主要针对MS-DOS。 It uses a DOS extender that's better than djgpp's, but that's pretty much damning with faint praise. 它使用的是比djgpp更好的DOS扩展器,但这几乎是一种愚蠢的赞美。 The compiler isn't really even very close to conforming with C++98; 编译器甚至不太符合C ++ 98; C++11 updates strike me as unlikely to come soon (if ever). C ++ 11更新让我觉得不太可能很快(如果有的话)。
  5. Digital Mars: Walter Bright now works mostly on his own D language. 数字火星:Walter Bright现在主要使用他自己的D语言。 Though a C++ compiler is still available, the C++ it compiles is fairly obsolete. 虽然C ++编译器仍然可用,但它编译的C ++已经过时了。

Summary: if you want an IDE, VC++ Express is the clear choice. 总结:如果你想要一个IDE,VC ++ Express是明智的选择。 If you care more about the latest C++11 features and don't mind working from the command line, MinGW is probably the top choice. 如果您更关心最新的C ++ 11功能并且不介意在命令行中工作,MinGW可能是最佳选择。 The others definitely have niches, but I'd consider most of them inferior if your aim is primarily to new, write portable C++. 其他人肯定有利基,但如果你的目标主要是新的,编写可移植的C ++,我会认为他们中的大部分都是劣等的。

I'm currently using the MinGW distro by Stephan Lavavej at http://nuwen.net/mingw.html 我目前正在使用Stephan Lavavej的MinGW发行版,网址为http://nuwen.net/mingw.html

I use it to produce .exe files using gcc. 我用它来生成使用gcc的.exe文件。

You just have to be happy with the collection of tools he has included. 你只需要对他所包含的工具集合感到满意。

Then I looked at Visual C++ 2010 since I already had it installed, but it looks like I need to install 2008 just to use .net framework 3.5 然后我看了Visual C ++ 2010,因为我已经安装了它,但看起来我需要安装2008只是为了使用.net framework 3.5

Uh, C++ and .NET have nothing whatsoever to do with each other. 呃,C ++和.NET 没有任何关系。

Visual Studio is the C++ compiler for Windows. Visual Studio是Windows C ++编译器。 Most of the others have poor Windows support at best. 其他大多数人的Windows支持最差。

我知道你提出的问题是“允许我传递小exe”但如果你有兴趣(比如我)有时只是运行C ++代码而不是创建exe,你可能想尝试编译和执行C ++ Online

对于Windows上的简单C / C ++编译器,很难击败djgpp: http//www.delorie.com/djgpp/

IMHO: Only way to have exe that is few kb this days is to do it with .net framework, say 2.0 to be as compatible as possible. 恕我直言:现在只有少数kb的exe的方法就是用.net框架来做,说2.0尽可能兼容。

I guess what ever tool you use, you'll statically link at least some parts of standard library, which will break your requirement for small exe. 我想你使用的工具,你至少会静态链接标准库的某些部分,这将打破你对小exe的要求。

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

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