Название: Beginning Programming with C++ For Dummies
Автор: Davis Stephen R.
Издательство: Автор
Жанр: Зарубежная образовательная литература
Серия: For Dummies
isbn: 9781118823934
isbn:
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.
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 installation should finish with Installation Was Successful.
Figure 2-6: You must install both Xcode and the Command Line Tools for Xcode to get the gcc compiler for Macintosh.
Installing Code::Blocks
Now, at last, you can finish your Mac OS installation by downloading the Code::Blocks package:
1. Open the Safari browser and go to www.codeblocks.org/downloads.
2. Click Downloads⇒Binaries.
3. Click Mac OS X.
4. Select either the BerliOS or the Sourceforge.net mirror site for the most recent version.
At the time of this writing, CodeBlocks-13.12-mac.zip was the most recent.
5. Install the downloaded Zip file into the Applications folder.
If you’ve never installed an application from a third-party site, you may need to execute these extra steps before you can do so:
a. Click System Preferences.
b. Click Security and Privacy.
c. Click the padlock in the lower-left corner of the window to allow СКАЧАТЬ