简体   繁体   中英

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.

First I found cygwin cause it had g++, but it requires cygwin.dll to run the exe's.

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)

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. 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.

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? (since it is only relevant to windows users)

Or should I just use C and go with gcc for mingw?

At least some of the obvious candidates:

VC++: As of VC++ 2010 is starting to support some C++11 features. VC++11 (currently in beta testing) adds a few more. 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. 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).

MinGW: STL's current package features gcc 4.7.0, which (at least arguably) has somewhat better C++11 support than VC++. It includes quite a few ported Unix/Linux tools, but is basically a command line-only environment. If you want something like an IDE, you'll have to install/configure it separately.

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. 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. 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. 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. If you want to write code using Qt it might well be your first choice. Otherwise, I'd probably avoid it -- while it probably can work fine otherwise, it's written assuming Qt as the default.

Eclipse/CDT: You can find this packaged with a copy of g++ as well. 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. Otherwise, I'd personally avoid it.

C++ Builder: In the Borland days, this was the biggest challenger to Microsoft's dominance. Embarcadero seems to be trying to get it back in the mainstream again. The emphasis here seems to be much more on the IDE, GUI toolkit, etc., than the compiler proper. The compiler itself seems to be somewhat behind gcc and/or 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.

Clang: The most recently started of the major compilers, but really working at being one of the best. 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. 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. On Windows, this a bit like buying a muscle car from a junk yard. 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.

A few more to generally avoid:

  1. Any version of VC++ before about 2008. Simply inferior implementation of C++.
  2. Any version of g++ before 4.x. Again, inferior implementation of C++.
  3. djgpp: pretty much the worst of the worst. This really targets MS-DOS with a (custom) DOS extender. An ancient version of gcc rounds out the awfulness.
  4. OpenWatcom: also primarily targets MS-DOS. It uses a DOS extender that's better than djgpp's, but that's pretty much damning with faint praise. The compiler isn't really even very close to conforming with C++98; C++11 updates strike me as unlikely to come soon (if ever).
  5. Digital Mars: Walter Bright now works mostly on his own D language. Though a C++ compiler is still available, the C++ it compiles is fairly obsolete.

Summary: if you want an IDE, VC++ Express is the clear choice. 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. The others definitely have niches, but I'd consider most of them inferior if your aim is primarily to new, write portable C++.

I'm currently using the MinGW distro by Stephan Lavavej at http://nuwen.net/mingw.html

I use it to produce .exe files using gcc.

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

Uh, C++ and .NET have nothing whatsoever to do with each other.

Visual Studio is the C++ compiler for Windows. Most of the others have poor Windows support at best.

我知道你提出的问题是“允许我传递小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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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