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.
The gcc compiler is readily available for Linux. Follow these steps to install it:
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++.
Enter the following command from a command prompt:
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++
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:
Click on the Software Center icon on the Ubuntu desktop.
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.
Select the Compiler Flags tab.
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
Select the Toolchain Executables tab.
Select the button.
Navigate to /usr, unless you installed your gcc compiler someplace other than the default location of /user/bin.
The C compiler should be gcc, the C++ compiler should be g++ and the Linker for dynamic libs should be g++.
Select OK to close the dialog box.