I am a new Ubuntu user. I started C++ programming in Windows using Code::Blocks, and would like to try the open source environment of Linux.

I am looking to set up Code::Blocks IDE to develop in C++. I have installed it and used it to create my first hello world application in Ubuntu. I tried to compile and run it, but it has a debugger issue and what appears to be a link issue. When I first started the first C++ test.cpp project, it asked me what compiler to use, and it automatically detected the GNU GCC Compiler which I selected.

Do I need to download anything from the repository to get my C++ code to run in Code::Blocks? Do I need to link anything in my build options that isn't done automatically?

  • I upvoted and favorited this because I need to know how Codeblocks and g++ configured properly to suite DevC++ in Ubuntu. – Ade Malsasa Akbar Jul 29 '14 at 15:56
  • yea i wish i could get some solid advice. everything I found isn't enough – chamburger Jul 29 '14 at 16:38

Your C++ program is not running in Code::Blocks because you do not have a C++ compiler (a version of G++) installed, or if it is installed you have not configured the C++ compiler in the Code::Blocks compiler settings. The C++ compiler is not configured for any version of g++ by default, so it has to be configured in the Code::Blocks compiler settings.

  1. Install the g++ compiler for C++

    sudo apt install g++ xterm 

    Optionally install gcc too if it is not already installed.

    sudo apt install gcc  
  2. Start Code::Blocks.

  3. Select Settings -> Compiler -> Global compiler settings (large blue gear icon in the left pane) -> Toolchain executables tab.
  4. Select the Program Files tab. It has already been selected in the below screenshot.
  5. Click the .. button(s) which are marked by the mouse cursor in the below screenshot. Navigate to /usr/bin. The C compiler should be gcc, the C++ compiler should be g++ and the Linker for dynamic libs should be g++.
  6. Click the     OK     button to close the Compiler settings window.

Note: It is permissible to install later versions of gcc and g++ from the default Ubuntu repositories alongside gcc and g++ and select them instead of gcc and g++ in the Code::Blocks compiler settings. The latest versions of gcc and g++ in 19.10 and 20.04 are gcc-9 and g++-9.

enter image description here

| improve this answer | |

Basically, Code::Blocks doesn't require any additional configuration. You should have installed g++ package. You can do it by issuing command

sudo apt-get install g++
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.