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.