One of the most common e-mails I receive about C++ All-In-One Desk Reference For Dummies is that people are receiving an error message about the compiler when they try to compile the examples. A common error message is:
SayHello2 – Debug uses an invalid compiler. Probably the toolchain path within the compiler options is not set up correctly?! Skipping … Nothing to be done.
The reason you’re having trouble is due to an error on the CD. It turns out that our production folks made a mistake in putting the book’s CD together. The product that we have on the CD is the IDE only and does not include the compiler. There is a quick solution to the problem should you wish to use it:
- Go to this page: http://www.codeblocks.org/downloads/5.
- Download the second item on the list, codeblocks-8.02mingw-setup.exe. That contains the compiler.
- Double click the file once the download is complete and follow the instructions to install the compiler.
If you’re using Windows Vista or Windows 7, the version of the MinGW compiler that comes with CodeBlocks might not work. (It does work on my copy of 64-bit Windows 7 and many other people have used it successfully, but a few people do run into problems.) In this case, you’ll need to go to http://www.mingw.org/ to download the latest version of the MinGW compiler as they suggest on the CodeBlocks Web site. You can also get the latest version of the compiler from http://sourceforge.net/projects/mingw/files/Automated MinGW Installer/. My writing partner, Jeff, suggests that you install:
- g++ compiler
- MinGW Make
into C:\MinGW to make the compiler easier for CodeBlocks to find. At this point, start the CodeBlocks compiler. Once it has started up, select Settings -> Compiler and Debugger. In the Compiler and Debugger Settings dialog box, click the “Selected Compiler” dropdown and choose the GNU GCC Compiler option. You should be good to go at this point. Please let me know if you experience any other problems at John@JohnMuellerBooks.com.