CodeBlocks in Ubuntu 18.04 doesn't show any result in Console after Build and Run. What should I do?

Output from CodeBlocks

I have just switched to linux.

Thanks in advance!

7

3 Answers

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++ in Ubuntu 18.04 by default, so it has to be configured in the Code::Blocks compiler settings.

  1. Install the latest version of the g++ compiler for C++.

    sudo apt install g++-8 xterm 

    Optionally install the latest version of gcc too (recommended).

    sudo apt install gcc-8-base # recommended version 
  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 either gcc or optionally gcc-8, the C++ compiler should be g++-8 and the Linker for dynamic libs should be g++-8.
  6. Click the     OK     button to close the Compiler settings window.

enter image description here

9

I tried to install codeblocks in bionic and it was almost a night mare as so many dependencies are needed. In the case of the question OP was missing the xterm terminal that codeblocks uses to work and that can be found in the libwxbase3.0-0v5 package, when you try to install this it will complain then you run sudo apt install -f and it will install xterm as part of the dependencies.

enter image description here

Please note that the codeblocks download comes with the dependencies needed in the archive filecodeblocks_17.12-1_amd64_stable.tar.xz from their down load site.

1

Maybe ur problem is that you saved the file in the default format (.ads) provided by codeblocks. I had the same problem but solved it after I renamed my file extension from .ads to .cpp.

Hope this helps

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like