Beginning Programming with C++ For Dummies. Davis Stephen R.
Чтение книги онлайн.

Читать онлайн книгу Beginning Programming with C++ For Dummies - Davis Stephen R. страница 7

СКАЧАТЬ alt="9781118823873-fg0201.tif" id="x7_z1"/>

      Figure 2-1: The C++ program development process.

      Most C++ compilers these days come in a software package known as an Integrated Development Environment or IDE. IDEs include the editor, the compiler, and several other useful development programs together in a common bundle. Not only does this save you from having to purchase the programs separately, but also offers productivity benefits by combining them into a single package:

      ✔ The editor can invoke the compiler quickly without making you switch back and forth manually.

      ✔ The editors in most IDEs provide quick and efficient means for finding and fixing coding errors.

      ✔ Some IDEs include visual programming tools that allow the programmer to draw common windows such as dialog boxes on the display.

      ✔ The IDE generates the C++ code necessary to display onscreen boxes automatically.

      

As nice as that sounds, the automatically generated code only displays the windows. A programmer still has to generate the real code that gets executed whenever the operator selects buttons within those windows.

      Invariably, these visual IDEs are tightly coupled into one particular operating system. For example, the popular Visual Studio is strongly tied into the .NET environment in Windows. It’s not possible to use Visual Studio without learning the .NET environment – and something about Windows – along with C++ (or one of the other .NET languages). In addition, the resulting programs only run in a .NET environment.

      In this book, you use a public-domain C++ IDE known as Code::Blocks. Versions of Code::Blocks exist for Windows, Linux, and Mac OS. Versions of Code::Blocks for these three operating systems (as well as a few others) are available for free download at www.codeblocks.org. The specific version used in the generation of the book is version 13.12. You can also download the Windows 13.12 binary at www.dummies.com/extras/beginningprogrammingcplusplus.

      You’ll use Code::Blocks to generate the programs in this book. These programs are known as console applications because they take input from – and display text back to – a console window. Okay, this isn’t as sexy as developing programs in onscreen windows, but staying with console applications lets you focus on C++ without being distracted by the requirements of a windowed environment. In addition, using console applications will allow the programs in the book to run the same on all environments that support Code::Blocks.

Installing Code::Blocks

      The following instructions take you through installing Code::Blocks on a Windows, Mac OS, or Linux computer. Jump to the section that applies to your operating system.

Windows installation

      This section provides detailed installation instructions for installing Code:: Blocks for Windows Version 13.12 available at www.dummies.com/extras/beginningprogrammingcplusplus.

      1. Download the file codeblocks-13.12mingw-setup.exe.

      That’s straightforward enough.

      2. Double-click the downloaded file to start the installation process.

      Depending on which version of Windows you’re using, you may a warning pop-up message like this one:

      Do you want to allow the following program from an unknown publisher to make changes to your computer?

      3. Select Allow.

      Setup unpacks the files it needs to start and run the Code::Blocks Setup Wizard. This process may take a minute. When it finishes, the startup window shown in Figure 2-2 appears.

      Figure 2-2: The Code:: Blocks Setup Wizard guides you through the installation process.

      4. Close any other programs that may be running and then select Next.

      The Setup Wizard displays the generic End User License Agreement (EULA). There’s nothing much here to get excited about.

      5. Select I Agree.

      The Setup Wizard then displays a list of the components that you may choose to install. See Figure 2-3. The defaults are okay.

      

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 СКАЧАТЬ