Monday 14 September 2009

How-To: Compile and Install Code::Blocks from Source in Debian Lenny

Code::Blocks is a complete, cross-platform integrated development environment for C and C++, built using the wxWidgets toolkit. Code::Blocks is available on Linux, Windows and OS X, so you may find it useful on Linux if you switched and are already used to it or an IDE like Dev-C++, for example.


The last stable version is 8.02, and was released almost an year ago. Since Code::Blocks is not included in the Debian repositories, I will show in this tutorial how to compile and install it from source in Lenny, the upcoming stable Debian release. Just follow the steps below:

1. Download the source and uncompress it
Download the source code from the official website, here, then make sure to switch the current directory to the one where you saved the source and uncompress it using the following command:

tar -xjf codeblocks-8.02-src.tar.bz2

2. Install the needed dependencies
This should be easy since only a few dependencies are needed. First, make sure you have the build-essential meta-package installed, which contains tools like make or g++, needed for compilation:

su
apt-get install build-essential

Next, install the development packages needed by Code::Blocks:

su
apt-get install wx-common libwxgtk2.8-dev libgtk2.0-dev

You will also need package zip to build it:

apt-get install zip

3. Update wx-config to point to wxWidgets 2.8
Issue the following command as root:

update-alternatives --config wx-config

What appears should look something like this:

# update-alternatives --config wx-config
There are 4 alternatives which provide `wx-config'.

Selection Alternative
-----------------------------------------------
1 /usr/lib/wx/config/base-unicode-release-2.6
+
2 /usr/lib/wx/config/gtk2-unicode-release-2.6

3 /usr/lib/wx/config/base-unicode-release-2.8

* 4 /usr/lib/wx/config/gtk2-unicode-release-2.8


Press enter to keep the default[*], or type selection number:
4
Using '/usr/lib/wx/config/gtk2-unicode-release-2.8' to provide 'wx-config'.

Select option 4 from the list, that is /usr/lib/wx/config/gtk2-unicode-release-2.8

4. Compile from source and install
Make sure the working directory is the uncompressed source of Code::Blocks (codeblocks-8.02) and issue the usual commands:

./configure
make
make install

The last one as root.

5. Run ldconfig as root
Finally, run the ldconfig utility as root to update the links to shared libraries:

su
ldconfig

Code::Blocks should be now properly installed in /usr/local/bin/ and you can run it using codeblocks from a terminal or from a run dialogue (ALT+F2 and type codeblocks in KDE and GNOME).

2 comments: