Code::Blocks in Linux Mint 17.2 and Ubuntu 14.04

codeblocks

Recently I ran into a problem finding a solution for properly installing Code::Blocks on a Linux Mint 17.2 Cinnamon machine. I had the option to opt in and run the application on a Windows lab machine, but I said nah, I want to expose myself more to the linux environment and I want to be able to use my own laptop. So I went ahead and opted to install Code::Blocks on my Linux Mint 17.2 laptop.

After much searching I came across an obscure reference in a forum post to the problem. What was happening is that when I included printf() and scanf() in my simple terminal application it wouldn’t compile or run, the compiler complained about an assumed reference. Code Blocks would also generate errors in regards to stdio.h and that it couldn’t find the file. After further reading the solution is part of the normal compiler/code blocks installation. I was not aware, I’ve never actually compiled code on linux before. Here is what I did to resolve it.

Start by checking that your gcc is up to date. You might not need to but it is always good to run the install as it will update your gcc if it needs to.

sudo apt-get update
sudo apt-get install gcc

The above if up to date, will skip over the installation and tell you that you already have the latest packages installed.

Now go ahead and install Code::Blocks.

sudo apt-get install codeblocks

This will install the application on your computer and you will be able to run it and create projects. However this is where I initially ran into an issue where if I Included stdio.h in the source it would generate an error. Something along the lines of…

… stdio.h: No such file or directory …

There are two things that you need to do to resolve this. You need to install build-essentials and xterm.

sudo apt-get install build-essentials

The above will install the dependencies such as the stdio.h file, however if you go to compile a simple application and run it in command line or bash you will get another error. Generally an XTerm error. You will need to also install XTerm in order for Code::Blocks to be able to open up a terminal window and execute the application.

sudo apt-get install xterm

Once you have all the above packages installed give it a go and you should be able to execute and run simple c/c++ code.

Advertisements

3 thoughts on “Code::Blocks in Linux Mint 17.2 and Ubuntu 14.04

  1. Nice tutorial. Now I can compile c++ with Code Blocks. But, I was unable to install Codeblocks essentials. It gives following error, anyway… My problem is now solved.

    $ sudo apt-get install build-essentials
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package build-essentials

  2. when i click the run option it shows in the log that process terminated with status -1…and it is not showing the output screen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s