8

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?

MxLDevs
  • 19,048
  • 36
  • 123
  • 194

6 Answers6

8

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

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
5

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.

ildjarn
  • 62,044
  • 9
  • 127
  • 211
quamrana
  • 37,849
  • 12
  • 53
  • 71
  • I just started using this too, not long ago. It's working wonderfully, and is the only GCC distribution I've found so far that works with Codeblocks running off of a flash drive. – chris Jun 07 '12 at 20:42
2

I know you're question mentions "allow me to pass around small exe's" but if you're interested (like me) in sometimes just running C++ code and not creating an exe, you might want to give Compile and Execute C++ Online a try.

NoonKnight
  • 153
  • 5
  • 8
  • That's definitely useful if I wanted to just write up a quick snippet and see if it works. Seems kind of slow, especially since compiling small pieces of code usually takes no time, but I guess that's the trade-off for not having to get a compiler myself. – MxLDevs Feb 07 '14 at 16:44
1

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.

Puppy
  • 144,682
  • 38
  • 256
  • 465
-1

For a simple C/C++ compiler on windows it's hard to beat djgpp: http://www.delorie.com/djgpp/

bearda
  • 301
  • 1
  • 8
-1

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.

Daniel Mošmondor
  • 19,718
  • 12
  • 58
  • 99
  • 2
    But if you do use .NET (any version) you're not longer writing C++ at all. The closest you can get is C++/CLI, which 1) Microsoft recommends *only* for interoperation, and 2) isn't really C++ anyway. – Jerry Coffin Jun 07 '12 at 20:31
  • Yes, but for small app, I would recommend c#. OP could get exe of 10kb size, and nearly EVERY windows computer has .net 2.0 installed. I wouldn't recommend c++/cli to even worst enemies, though :) – Daniel Mošmondor Jun 07 '12 at 20:32
  • What can I use to build in .net 2.0? Microsoft has a 2.0 SDK but it's a large download (350+ MB) and if there's something else I can use that would be helpful. – MxLDevs Jun 07 '12 at 20:34
  • VS 2005 Express will do. http://stackoverflow.com/questions/780741/where-is-visual-studio-2005-express – Daniel Mošmondor Jun 07 '12 at 20:37
  • Thanks! I guess new versions of VS don't want to provide support for older frameworks :( – MxLDevs Jun 07 '12 at 20:43
  • They indeed do, but I remember (faintly) that VS2010 has _some_ issues with .net 2.0, but I'm sure that VS2008 works perfectly with 2.0 as target, since that's the environment I use every day. – Daniel Mošmondor Jun 07 '12 at 20:44
  • VC++2005 can still (in native mode, no .Net) build executables as small as 4kB, if you know what you're doing. But 8kB is a more realistic target. – MSalters Jun 08 '12 at 07:29