Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

How to Install C++ Code::Blocks in Ubuntu Linux

Code::Blocks for C++ does not include gcc on Linux, so installation is a two-step process. First you will 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 and, in particular, not 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

    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 are 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 on the Software Center icon on the Ubuntu desktop.

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

    This will start the installation process.

    Code::Blocks searches your hard drive for your C++ compiler. It should be able to find it without a problem, but if it doesn’t, then execute the following steps.

  3. Start Code::Blocks.

  4. Select Settings→Compiler.

  5. Select the Compiler Flags tab.

  6. Make sure that the following three flags are selected, as shown in this figure:

    • Enable All Compiler Warnings

    • Have g++ Follow the Coming C++0x ISO C++ Language Standard

    • Have g++ Follow the C++11 ISO C++ Language Standard

      image0.jpg
  7. Select the Toolchain Executables tab.

  8. Select the “…” button.

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

  10. The “C compiler” should be gcc, the “C++ compiler” should be g++ and the “Linker for dynamic libs” should be g++.

  11. Select OK to close the dialog box.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.