Beginning Programming with C++ For Dummies. Davis Stephen R.. Читать онлайн. Newlib. NEWLIB.NET

Автор: Davis Stephen R.
Издательство: Автор
Серия: For Dummies
Жанр произведения: Зарубежная образовательная литература
Год издания: 0
isbn: 9781118823934
Скачать книгу
It’s absolutely critical that the MinGW Compiler Suite option appear onscreen and have a check mark next to it. This is the option that installs the C++ compiler.

      6. Select Next.

      The next window asks you to choose the installation’s location. This window also tells you how much space Code::Blocks requires on your hard drive (about 250MB, depending on the options you’ve selected) and how much space is available. If you don’t have enough free disk space, you’ll have to delete some of those captured YouTube videos to make room before you continue.

      Figure 2-3: Checking the MinGW Compiler Suite installs the GNU C++ compiler that Code:: Blocks uses to compile your programs.

      7. The default installation location is fine, so when you’re sure you have enough disk space, click Install.

      At this point, the Code::Blocks Setup Wizard really goes to work. It extracts umpteen dozen files that it installs in a myriad of subdirectories in a flurry too complicated for mere mortals to follow. This process may take several minutes.

      8. When the installation is complete, a dialog box appears asking you whether you want to run Code::Blocks now. Select No.

      If all has gone well so far, the Installation Complete window shown in Figure 2-4 appears.

      Figure 2-4: The Installation Complete window signals that Code:: Blocks has been successfully installed.

      9. Click Next.

      Finally, the Completing the Code::Blocks Setup Wizard window appears. This final step creates the icons necessary to start the application.

      10. Click Finish.

      You’ve installed Code::Blocks but you still need to make sure that it’s set up properly for the programs in this book. Jump to the “Setting up Code::Blocks” section farther along in this chapter.

Ubuntu Linux installation

      Code::Blocks does not include the gcc compiler in the Linux installation, so installation is a two-step process. First you’ll need to install gcc. Then you can install Code::Blocks.

       Installing gcc

      The gcc compiler is readily available for Linux. Follow these steps to install it:

      1. Enter the following commands from a command prompt:

      sudo apt-get update sudo apt-get upgrade sudo apt-get install g++

      The standard Ubuntu Linux distribution includes a GNU C compiler, but it does not include the C++ extensions; in particular, it doesn’t have the C++ 2011 standard extensions. The first two commands update and upgrade the tools you already have. The third command installs C++.

      2. Enter the following command from a command prompt:

      gcc – version

      My Ubuntu 13.04 downloaded GNU C++ version 4.7.3. You’ll be fine with version 4.7.1 or later. If you have an earlier version, some of the C++ 2011 features may not work properly, but otherwise it should be okay.

      

If you’re using Debian Linux, the commands are the same. If you’re using Red Hat Linux, replace the command apt-get with yum so that you end up with

      sudo yum install g++

       Installing Code::Blocks

      Fortunately for all concerned, an Ubuntu-ready version of Code::Blocks is available in the Ubuntu Software Center. Many other versions of Linux include something similar to the Software Center. Follow these steps to install Code::Blocks:

      1. Click the Software Center Icon on the Ubuntu desktop.

      2. Select Code::Blocks from the list of available software.

      The installation process starts.

      Code::Blocks searches your hard drive, in quest of your C++ compiler. If Code::Blocks finds your C++ compiler,, you’re done.

      

If Code::Blocks doesn’t find your C++ compiler, then execute the following steps.

      3. Start Code::Blocks.

      4. Select Settings⇒Compiler.

      5. Select the Compiler Flags tab.

      6. Select the Toolchain Executables tab.

      7. Select the "…" icon.

      8. Navigate to /usr, unless you installed your gcc compiler someplace other than the default location of /user/bin.

      9. Set the following options in the dialog box: “C compiler” should be gcc, the “C++ compiler” should be g++ and the “Linker for dynamic libs” should be g++.

      10. Select OK to close the window.

      Jump to the “Setting Up Code::Blocks” section of this chapter to make sure that Code::Blocks is set up properly for the programs in this book.

Mac OS installation

      The Macintosh version of Code::Blocks relies on the Xcode distribution from Apple for its compiler.

       Installing Xcode

      Xcode is a free development package offered by Apple; you’ll need it. Follow these steps to install it first:

      1. Open the Safari browser and go to http://developer.apple.com.

      2. Click Download Xcode to get the most recent version.

      This will open the Xcode download dialog box shown in Figure 2-5.

      Figure 2-5: The Xcode download dialog box allows you to install Xcode for free.

      3. Click the Free icon to change it to Install App. Click it again.

      4. Enter your system password (the one you log in with when your Mac boots up).

      The icon changes to Installing.

      The download and installation takes quite some time, as Xcode takes up a little over 2GB as of this writing.

       Installing the Command Line Tools

      As big as Xcode is, you might think that it has everything you need, but you’d be wrong. You need one more package from Apple to make your joy complete and to get a working gcc compiler on your Macintosh. Follow these steps to install the Command Line Tools for Xcode:

      1. Open the Safari browser and go to http://developer.apple.com/downloads.

      You may be asked to sign up for an Apple Developer ID. Go ahead and do so – it’s free. Provide your existing developer ID if you already have one.

      2. Search for Command Line Tools for Xcode. Select the application. See Figure 2-6.

      3. Double-click the mpkg package when it downloads; doing so installs it.

      4. Accept all the default values.

      The