views:

637

answers:

9

Hello,

I'm using Windows Vista Ultimate and i want to know what is the best C++ compiler for my Windows, because in Linux i use in somee cases gcc and in others g++, but recently i've installed Windows in my computer and this is the question: What is the best C++ compiler for Windows? Thanks!

+14  A: 

Microsoft Visual C++ 2008 Express, it's free. http://www.microsoft.com/express/vc/

or if you're an open source guy: http://www.mingw.org/ HOWTO: http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite

M4dRefluX
Correct, but it installs the compiler along with it. See my edit.
M4dRefluX
Thanks, now it's a compiler!
Nathan Campos
VC++ 2k8 Express comes with a compiler. The compiler can be accessed as a command line tool, so this is still a good suggestion even if you don't intend to use the IDE.
Darryl
You can actually download the compiler on it's own. I think it's part of thw WindowsSDK?
Pod
+3  A: 

You can get gcc and g++ through either cygwin or mingw.

Cygwin provides a full layer of POSIX compatibility to implement UNIX and Linux features,such as forking, on top of Windows. This slows things down, but ensures that your UNIX programs will work on Windows. Due to this compatibility layer, you must include a cygwin .dll file with your applications.

MinGW provides a suite of GNU tools that run on Windows natively. This is faster than Cygwin and requires no extra DLL, but does not have the same amount of feature support. This means that not all your UNIX applications can be used on Windows.

Note that when I say that you can use UNIX applications, I mean that they must be built from source; neither of these runs UNIX or ELF binaries.

Either one of these will provide you gcc, which (IMO) is the best compiler, especially if you will be using UNIX and Windows, in which case gcc won't break your build chain.

samoz
+1  A: 

You have 2 obvious choices, Microsoft's one (mvcc) or gcc/g++ (using MinGw). It's actually hard to say which one is better, I've done a lot of benchmarks with my colleague (and a lot more you can find on internet) and we had various results.
Btw, you can use ms visual studio IDE with both of them (to use g++, you have to spend some time configuring stuff), so choosing Microsoft Visual Studio doesn't pin you down to their compiler.

Ravadre
+1  A: 

There are windows ports of the the GNU Compiler Collection which you may be intrested in if you dont want to use the free Visual Studio C++ IDE (which I highly recommend). MinGW is a gcc port which comes to mind, although ive never used it.

EDIT: It is possible to set VS up to use compilers other than the VC9 one, however ive never tried this and am not sure if its support for the free express editions of Visual Studio.

Fire Lancer
+2  A: 

You can use mingw as M4RefluX or cygwin if you are more a *nix guy or the free compilers from borland or the Express editions from Microsoft that I think you can use from the command line.

Aragorn
Personally, I prefer the Microsoft compiler. It's the best on Windows without a doubt.
M4dRefluX
+1  A: 

If you've come from the Linux world and are used to GCC/GNU ware then GCC with CygWin/Mingw is probably going to be the easiest transistion for you. VS C++ is nice but it's a completely different flow than what you're used to. Other than that IF you want to do .NET applications, not assuming you do, VS is probably the way to go.

Quality vs Performance? I'd wager are going to be simalar. GCC can generate good code, but VS probably can take advantage of insider information at Microsoft.

Compatability With Linux? Cygwin over Mingw. Cygwin goes above and beyond to try and be compatable. MingW is intended to be a freeware solution to Win32 development and uses a minimal interface layer compared to Cygwin which tries it's best to look like Linux from a development perspective.

Pete

NoMoreZealots
"VS probably can take advantage of insider information at Microsoft." - I didn't know x86 was a MS thing.
mackenir
I mean when targeting Windows, i.e. undocumented OS "stuff". Actually you bring up a good point, Intel has thier compiler which butts head with GCC from time to time on performance.
NoMoreZealots
+4  A: 

The Best is kind of hard to define.

Visual C++ is the most common one, and perhaps the most cost effective. There are some free ones and I'm not familiar with them.

As far as speed optimization, the Intel C++ compiler is the best, but it's rather costly.

Asaf

Asaf R
Good point, the "best" requires some qualification in terms of how it's being used/applied.
NoMoreZealots
+2  A: 

Unless you have very specific needs compiler isn't really the important question. What really matters is the IDE. You have 2 main options for IDE

For actual compilers you have:

  • CL - The compiler from visual studio. Generally a good compiler. It has really gotten good in the last 5 years or so.
  • The Intel Compiler - For pure speed nothing beats it. It is just a drop in into visual studio so if you are using that it's simple to use.
  • g++ - The easist way to make this work is use MinGW
Matt Price
A: 

From my recent experience with Qt, the MS compiler generates smaller EXE/DLL files - usually between 15%-20% smaller. The linker seems to be better at removing unused code, although compiling without exception handling in gcc can improve things. The MS debugging tools also seem to be a lot faster than gdb.

However, this was with gcc v3.4.5 which is about 5 years old. Luckily a new version of MinGW (the gcc Windows port) is available (v4.4) which is meant to be much better (according to the Qt blog it is a much faster compiler than it's predecessor.)

What sort of development are you doing? You might want to give Qt and their IDE, Qt Creator, a look.

Rob