How do I determine which C/C++ compiler to use?

23,601

Solution 1

First of all, IMHO as a beginner your development environment (IDE) matters a lot more than the compiler.

I think that people place too much emphasis on compiler choice early on. While it is not Java, C++ is meant to be portable.

If the program you're writing only works with specific compilers, you're probably doing the wrong thing or can work a little on making it more portable.

If you get to a point where compiler choice makes a significant performance impact for you, then you've already perfected everything else in your program and you're in a good state and you are also quite advanced in your abilities. We used to teach the differences between compilers at fairly advanced stages in the CS curriculum.

If you use a UNIX based machine (Linux, Mac, actual Linux), then pretty much GNU (g++) is the way to go and is fairly much standard. If it's good enough to compile your OS, it's probably good enough for you. On a mac you can use XCode as your IDE, and it interfaces well with g++. On Linux some people prefer command line tools, though you might like the Eclipse C++ support, it is much better today than it was 3-4 years ago.

Things on Windows are trickier. If you can afford it, have access to, or are eligible for one of the free editions (e.g., via a school), I think the Microsoft Visual C++ Environments (or whatever they are called now) are pretty good for learning and they are used in production. I think there's actually a lightweight visual studio now with an emphasis on C++ that could be a good start. If you don't, you can probably find a distribution of Eclipse that is specific for C++ and includes an implementation of the GNU compilers.

Solution 2

Use gcc and g++ while you're still learning these languages, a big enough task for now. If you need a specialized compiler down the road, you'll want to have much deeper understanding of the language and your problem domain to properly evaluate candidates.

Solution 3

I feel that if it is open source then it will be a more complete compiler since many programmer perspectives are used to make it better.

That's not necessarily true. You could also say that if you use Microsoft's compiler, it will be optimal for Windows, since Microsoft knows best how to optimize a compiler for Windows.

Microsoft has Visual C++ Express Edition which is free and ofcourse includes a nice IDE that's very well suited for Windows development.

But if you're interested in making portable software, look at GCC, which is the default compiler on Linux and which is also available on the Mac. (The iPhone works totally different and requires special tools that only run on Mac OS X). You can get GCC for Windows with Cygwin or MinGW.

Solution 4

Get the Visual Studio Express (easier and quicker IMO, to setup) and learn with it; when you think you know enough about C++ and how "things" work, you could start using something like QT or GCC (with cygwin) and learn to port to different platforms.

Solution 5

I strongly suggest going with MinGW.

It is:

  • Open-source
  • Available on all major platforms
  • Comes with standard Win32 headers and libraries
Share:
23,601
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to figure out which C/C++ compiler to use. I found this list of C/C++ compilers at Wikipedia:

    http://en.wikipedia.org/wiki/List_of_compilers#C.2FC.2B.2B_compilers

    I am fairly certain that I want to go with an open source compiler. I feel that if it is open source then it will be a more complete compiler since many programmer perspectives are used to make it better. Please tell me if you disagree.

    I should mention that I plan on learning C/C++ mainly to program 2D/3D game applications that will be compatible with Windows, Linux, MAC and iPhone operating systems. I am currently using Windows Vista x64 OS.

  • CMircea
    CMircea almost 14 years
    The toolkit is called Qt (upper Q, lower T); QT is QuickTime (upper Q and T).
  • Admin
    Admin almost 14 years
    I am using Windows Vista x64. I searched for the best IDE for C/C++ and most people are saying Microsoft Visual Studio but, I want to develop for all operating systems, not just Windows OS (XP/Vista/7). I have read that it is important to consider portability when choosing an IDE.
  • Uri
    Uri almost 14 years
    If you're developing a game, you'll probably be using a 2D/3D graphics API that is proprietary to a platform, like DirectX vs. OpenGL vs. Whatever is used on the iPhone. If you're just learning C++ and using standard libraries, then your code will easily be portable regardless of the OS or compiler that you use.
  • Admin
    Admin almost 14 years
    Well I plan on taking all the C/C++ code I write on my Windows Vista machine over to the MAC environment at a later date. I don't think Visual C++ Express will be a smart choice for me to start out in. I might as well just jump right into GCC and Cygwin. What IDE would be well suited for GCC for Windows and Cygwin?
  • Admin
    Admin almost 14 years
    I see. Perhaps you are right. After all I am just a beginner. Something to consider certainly. Thanks.
  • Jesper
    Jesper almost 14 years
    There is for example Code::Blocks codeblocks.org which is free and available for Windows, Linux and Mac OS X. You could also use Eclipse or NetBeans for C++ developments, although those are primarily Java IDEs. You need to install GCC on your system and then those IDEs will use that to compile your code.
  • josesuero
    josesuero almost 14 years
    @Potatoswatter: compared to what?
  • user168715
    user168715 almost 14 years
    @Adam: No, portability is almost completely orthogonal to IDE choice IMO. Pick your favorite IDE, use it to write portable code (ie avoid compiler extensions that come with the IDE's compiler), then when you're done take that code and compile it on your other target platforms, possibly using a different compiler. For instance, I write most of my programs using Visual Studio, then use gcc to compile the project on OS X/Linux. The downside is that when I port I have to write a separate makefile (MSVC doesn't use them), which is a pain but worth it.
  • Dennis Zickefoose
    Dennis Zickefoose almost 14 years
    Using gcc and g++ on their own is a hassle that you shouldn't have to deal with when learning. The benefits of a proper IDE, with built in debugging, build management, and such simply can not be ignored while you are still learning the language. Simply using g++ doesn't magically make your code portable, after all; you still have to chose cross-platform libraries.
  • o0'.
    o0'. almost 14 years
    IMHO IDEs are terrible for learning: you end up with tons of code not created by you that you don't really understand.
  • Nathan Osman
    Nathan Osman almost 14 years
    On Windows, actually, Code::Blocks comes with MinGW :)
  • Nathan Osman
    Nathan Osman almost 14 years
    Cygwin is nice, but may be a problem if you are developing commercial applications.
  • rmeador
    rmeador almost 14 years
    You can use gcc (mingw) on windows without Cygwin
  • Pavel Minaev
    Pavel Minaev almost 14 years
    Cygwin is a bad choice if you want truly portable code - it can easily push you towards Unixisms. MinGW is a decent middle ground. That said, if you stick to a reasonable subset of standard C++ (the only thing to be wary of are exception specifications), you can compile with MSVC on Windows and g++ elsewhere. I worked in such a (production) environment for two years in the past, and we had a very large codebase which was handled that way without much trouble.
  • Dennis Zickefoose
    Dennis Zickefoose almost 14 years
    @Lo'oris: What you mean to say is that "code wizards" and the like are terrible for learning. Don't throw out the baby with the bath water; code generation is the least important part of a good IDE.
  • Dennis Zickefoose
    Dennis Zickefoose almost 14 years
    I will admit that using VS can make it more difficult to understand the compilation process; its easier to understand linker errors for instance if you have to build things by hand a few times. But in my experience, people using command line tools to learn end up either ignoring multiple source files, or else using a build process that boils down to g++ *.cpp, neither of which are much more useful than just letting the IDE handle the tricky parts.
  • Nathan Ernst
    Nathan Ernst almost 14 years
    +1 @user168715 I completely agree with this sentiment, although I tend to go the other direction (write using vim, build/debug mostly using GNU tools, build/test on Windows, backport any changes to Linux, repeat until the same codebase works on both). Slight disagreement - MSVC does support Makefiles (I use this to build using VS2008, but with the VC7.1 compiler), they're just not in entirely the same form as GNU makefiles :/.
  • Nathan Ernst
    Nathan Ernst almost 14 years
    Also, if you wanted to use a GNU makefile, it is technically possible, but you'd have to build using an external command rather than internal targets, and your experience using VS as an IDE is going to rapidly diminish...
  • hhafez
    hhafez almost 14 years
    Available on all major platforms? Does that mean it is available for linux :p
  • Ben Voigt
    Ben Voigt almost 14 years
    MinGW is a particular build of gcc for Windows.
  • Nathan Osman
    Nathan Osman almost 14 years
    @hhafez: It is available for Linux. In fact, a lot of people use it to build Windows applications on Linux. Then they test them in WINE.
  • hhafez
    hhafez almost 14 years
    Ofcourse it's not available for linux, MinGW is specifically for windows (hence windows) so not it's not available for all major platforms, what is available for most major platforms is GNU software which is not equivalent to minGW
  • Nathan Osman
    Nathan Osman almost 14 years
    @hhafez: MinGW is available for linux - check your package manager - it'll be there.
  • hhafez
    hhafez almost 14 years
    What you are talking about is a cross compiler on linux to build mingw binaries, that is different than what I thought you meant (mingw enviroment on linux). They are two different things but I know what you mean now
  • Nathan Osman
    Nathan Osman almost 14 years
    @hhafez: Sorry for the confusion :)