CodeBlocks on a Macintosh

You probably read the post entitled, “Getting CodeBlocks to Work” regarding my book, “C++ All-In-One Desk Reference For Dummies“, and immediately thought it didn’t apply because you have a Macintosh. Rather than write a single confusing post, I decided to write a second post just for Macintosh developers.  Here are the instructions for the Macintosh:

  1. Go to this page: http://www.codeblocks.org/downloads/5 .
  2. Download the Macintosh version of the compiler, codeblocks-8.02-p2-mac.zip. That contains the compiler.
  3. Double click the file once the download is complete and follow the instructions to install the compiler.
  4. 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” drop down and choose the GNU GCC Compiler option.  You should be good to go at this point.


I wrote these instructions with the help of a friend with a Macintosh. While the examples in the book work just fine on a Macintosh, I don’t have a lot of Mac experience. If this fix doesn’t work, we may have to work together a bit to come up with a solution.  This solution did work for two other Macintosh readers, so I’m hoping it also works for you, but I’m more than happy to work with you to make sure you get a working setup. Feel free to write me at John@JohnMuellerBooks.com with your ideas and suggestions for a better procedure. You must have a copy of Mac OS X 10.4 or later to use CodeBlocks!

Getting CodeBlocks to Work

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:

  1. Go to this page: http://www.codeblocks.org/downloads/5.
  2. Download the second item on the list, codeblocks-8.02mingw-setup.exe. That contains the compiler.
  3. 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:

  • MinGWbaseTools
  • 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.

Moving from 32-bits to 64-bits

64-bit processors have been around for a long time now. Unlike the move to 32-bit processors, the move to 64-bit processors has been sluggish. In fact, if the move goes any slower, we’ll still be using 32-bit processors ten years (or more) from now. The main reason that the move to 64-bit processors has been so incredibly slow is that users are basically happy with their 32-bit setups. There isn’t any compelling application that makes the move to a 64-bit environment necessary, or even desirable. So, we still have 32-bit Windows XP enjoying a huge market share. It wasn’t until October 2010 that its market share finally fell below 60 percent.

However, the environment is beginning to change for a number of reasons. For one thing, Windows XP is becoming less secure as Microsoft starts to view it as an old OS past its prime. Yes, you still get security updates for Windows XP, but it’s only a matter of time before those updates become ineffective; the platform is simply becoming outdated and hard to maintain.

Anyone who has worked with Vista knows that the platform has problems. In fact, I tried my best not to work with it unless absolutely necessary. Windows 7 is a different story. I’ve been using it now for quite a few months without any problems at all. In fact, except for a few problem applications, I don’t even notice the Windows 7 differences any longer; it has become part of the background for me, as it has become part of the background for many people.

Windows 7 works best as a 64-bit operating system. I tried it as a 32-bit operating system and found that it lacked pep. A memory upgrade and moving to Windows 7 64-bit have made all the difference in the world. I now consider Windows 7 a true upgrade to Windows XP and hope that people begin moving to it en masse soon.

Microsoft has also made the move to 64-bits in some of the server products it offers. For example, Microsoft Exchange comes only as a 64-bit product now, as does SharePoint. Consequently, many organizations are beginning the arduous upgrade to 64-bit operating systems on their servers.

Using a 64-bit setup does have significant advantages. Of course, there is the availability of additional memory to consider. It’s also possible to perform certain code optimizations on a 64-bit system that you can’t achieve using 32-bits. Of course, if you want to obtain the full benefits of a 64-bit platform, you need 64-bit applications. Some developers are worried about the consequences of this move and for good reason. Making the move to the 64-bit environment is fraught with unexpected pitfalls. My latest article, “10 Biggest Issues for Developers Migrating 32-bit Applications to 64-bits”, explains some of the most common problems that developers encounter when moving their applications to the 64-bit environment. Give it a read and let me know what you think at John@JohnMuellerBooks.com.