Choosing the GNU C++ Compiler

This is an update of a post that originally appeared on April 23, 2012.

A number of readers have written to ask me about the reason I chose the GNU C++ computer for C++ All-In-One for Dummies, 4th Edition. After all, there are many different C++ compilers on the market today. Here are the reasons I feel that the GNU C++ Compiler is the best choice today:

  • Standards Adherence: From what I’ve read and seen in my own coding efforts, the GNU C++ compiler adheres a bit better to the current standards. There are other compilers, such as Microsoft’s Visual C++, that include a host of special additions and exceptions that don’t adhere to the standard. Given the audience for this book, using a compiler that’s strong on the standards is a must. (This book doesn’t use any of the GNU C++ extensions.)
  • Cross-Platform Compatibility: This book has a mixed audience. I’ve received so many e-mails from Macintosh readers that I’ve provided a number of blog posts just for this group. Linux developers also like this compiler and have used my book to learn how to use it. Because there are so many different platforms that this compiler works on, I can reach a much broader audience with the book and help more people write applications in C++ as a result.
  • CodeBlocks Support: In order to write good C++ code, you really do need a good IDE. CodeBlocks is a free compiler that works well on Linux, Macintosh, and Windows machines. If I had chosen another compiler, it may not have been possible to provide great support for all three platforms and some readers would have been left out.
  • Community Support: Both the GNU C++ compiler and CodeBlocks enjoy a broad range of support from the open source community. Getting help with either product is relatively easy and normally free.
  • Cost: Many of the readers of this book are students of limited means or are hobbyists learning to write C++ applications on a shoestring. Using the GNU C++ compiler coupled with CodeBlocks offers a method of teaching C++ programming that doesn’t require any investment by the reader. If cost hadn’t been a factor, there are probably other compilers on the market that might be a little better choice than using GNU C++.
  • Mobile Device Support: Many of my readers now what to be able to code from anywhere at anytime using their mobile device. Quite a few of the online compilers rely on GNU C++. (You also find support for Android devices in the book now using CppDroid in Chapter 2.) In many respect, you could view this as a fourth supported platform for my book.

Yes, I could have used some other compiler when writing this book, but at the time, GNU C++ seemed to be the best choice available and I still think it’s the best choice today. Of course, it’s always nice to hear about alternatives. If you think there is a strong competitor for GNU C++ that’s free and runs on all three of the target platforms for this book, let me know at [email protected]. Make sure you provide me with complete information, including a URL for the compiler’s site.

Checking Your Compiler in Code::Blocks

This is an update of a post that originally appeared on April 6, 2011.

Compilers are important because they turn your human-readable source code into executable code that the computer understands. Selecting the right compiler is essential if you want to obtain the best results from your application. Some readers have asked, “Just how do you select a compiler when working with C++ All-In-One for Dummies, 4th Edition?” The book assumes that you’re using the GNU GCC Compiler setting and there isn’t any guarantee another compiler will work with the book’s source code. Use these steps to check your compiler setting.

  1. Open the Code::Blocks application.
  2. Choose Settings | Compiler and you see the Global Compiler Settings dialog box shown here:
    A display of the Global Compiler Settings dialog box in Code::Blocks.
  3. Choose GNU GCC Compiler in the Selected Compiler field as shown in the figure.
  4. Click OK.

You should be ready to work with the book’s code at this point. Let me know if you have any problems choosing the right compiler at [email protected].