tags:

views:

868

answers:

14

What are some suggestions for easy to use C++ compilers for a beginner? Free or open-source ones would be preferred.

+1  A: 

Microsoft Visual Studio Express Edition of their C++ compiler is good

Keith Nicholas
+18  A: 

GCC is a good choice for simple things.

Visual Studio Express edition is the free version of the major windows C++ compiler.

If you are on Windows I would use VS. If you are on linux you should use GCC.

*I say GCC for simple things because for a more complicated project the build process isn't so easy

Matt Price
+3  A: 

I'd recommend using Dev C++. It's a small and lightweight IDE that uses the mingw ports as the backend, meaning you'll be compiling the the defacto C/C++ compiler, gcc

toluju
use this link for dev C++ instead http://sourceforge.net/projects/dev-cpp/
AlexanderN
+4  A: 

G++ is the GNU C++ compiler. Most *nix distros should have the package available.

JonathanMueller
+2  A: 

You can always use the C++ compiler from the Gnu Compiler Collection (GCC). It is available for almost any Unix system on earth, BSDs, Mac OS, Linux, and Windows (via Cygwin or mingw).

A number of IDEs are supporting the GCC C++ compiler, e.g. KDevelop under Linux/KDE, or Dev-CPP as mentioned in other posts.

MP24
+3  A: 

For a beginner: g++ --pedantic-errors -Wall

It'll help enforce good programming from the start.

Tom Ritter
+1  A: 

CodeBlocks is a very good IDE that can use besides many other compilers CL.EXE (from visual studio) and gcc. It comes also in a version with gcc included.

Visual Studio Express edition is avery good choice also (with Platform SDK if you will develop application that call winapi functions).

Iulian Şerbănoiu
+3  A: 

gcc with -Wall (enable all warnings) -Werror (change warnings into errors), -pedantic (get warnings for non-standard code) and -ansi (make the standard c++98).

If a warning is something you're aware of and need to turn off, you can always turn them back into warnings.

+1  A: 

Eclipse is a good one for mac, or Apple's own free Xcode which can be d/l'd off their development site.

+3  A: 

I recommend gcc because it's designed to be used on the command line, and you can compile simple programs and see exactly what's happening:

g++ -o myprogram myprogram.cc
ls -l myprogram

One file in, two files out. With Visual C++, most people use it with the GUI, where you have to set up a project and the IDE generates a bunch of files which can get in the way if you're just starting out.

If you're using Windows, you'll choose between MingW or Cygwin. Cygwin is a little work to set up because you have to choose which packages to install, but I don't have experience with MingW.

magpulse
A: 

Visual Studio in command line behaves just like GCC. Just open the Visual Studio command line window and:

c:\temp> cl /nologo /EHsc /W4 foo.cpp
c:\temp> dir /b foo.*
foo.cpp  <-- your source file
foo.obj  <-- result of compiling the cpp file
foo.pdb  <-- debugging symbols (friendly names for debugging)
foo.exe  <-- result of linking the obj with libraries

Leonardo Constantino
+1  A: 

One reason to use g++ or MingW/Cygwin that hasn't been mentioned yet is that starting and IDE will hide some of what is going on. It will be incredibly useful down the road to understand the differences between compiling and linking for instance. Learn it and understand it from the start, and you won't even know you should be thanking yourself later.

-Max

A: 

I agree with Iulian Șerbănoiu: Code::Blocks is a very good solution, usable both from Linux (it will use g++/gcc) and from Windows (it will use either the MS compiler or gcc)

Note that you should at least once or twice try to compile using a good old makefile, if only to understand the logic behind headers, sources, inclusion, etc. etc..

As a beginner, don't forget to read books about C++ (Scott Meyers and Herb Sutter books come to the mind, when trying to learns the quirks of the language), and to study open source high profile projects to learn from their code style (they already encountered the problems you will encounter, and probably found viable solutions...).

paercebal
A: 

I say GCC for simple things because for a more complicated project the build process isn't so easy

True, but I don't think understanding the build process of a large project is orthogonal to understanding the project itself. My last job I worked at, they had a huge project that needed to build for the target platform (LynxOS) as well as an emulation environment (WinXP). They chose to throw everything into one .VCP file for on windows, and build it as one big executable. On target it was about 50 individual processes, so they wrote a makefile that listed all 3000 source files, compiled them all into one big library, and then linked the individual main.cpp's for each executable with the all-in-one library, to make 50 executables (which shared maybe 10% of their code with the other executables). As a result, no developer had a clue about what code depended on any other code. As a result, they never bothered trying to define clean interfaces between anything, because everything was easily accessible from everywhere. A hierarchical build system could have helped enforce some sort of order in an otherwise disorganized source code repository.

If you don't learn how .cpp files produce object code, what a static library is, what a shared library is, etc., when you are learning C/C++, you do still need to learn it at some point to be a competent C/C++ developer.

KeyserSoze