Installing Code

Blocks c/c++ IDE on Ubuntu 8.04 (Hardy Heron)

The installation on Ubuntu 8.04

LGP provides fresh Ubuntu-packages for the codeblocks IDE.

You need to edit your /etc/apt/sources.list file
$ sudo gedit /etc/apt/sources.list

And add the following two lines to it.

# Repository for the codeblocks IDE packages
deb hardy universe

The packages are signed with a security key. Add this public key to your package system.  Run this command
$ wget -q -O- | sudo apt-key add –

Then install
$ sudo apt-get update
$ sudo apt-get install libcodeblocks0 codeblocks libwxsmithlib0 codeblocks-contrib

For code development, you’ll also need some additional packages. Install
$ sudo apt-get install build-essential gdb subversion

$ sudo apt-get install automake autoconf libtool

$ sudo apt-get install libgtk2.0-dev libxmu-dev libxxf86vm-dev

These package are for programming with the wxWidgets GUI toolkit. Code::blocks itself is a pure wxWidgets product.
$ sudo apt-get install libwxbase2.8-dev wx2.8-headers libwxgtk2.8-dev

Then start the codeblocks IDE from the menu or the CLI (command line interface):
$ codeblocks

The first launch will ask the compiler name. The default c/c++ compiler in Linux is “GNU GCC compiler”.

Below are some important notes. Especially read the notes 1- 5.
Use the (glut) freeglut library to develope portable OpenGL applications. Read note 1.
Code::Blocks has a GLUT project wizard. Use it to create your first OpenGL project. Build & run.

Some important notes.

Alguns comentários importantes.

[ Note 1 ]
If you want to develope OpenGL (glut…) applications, install FreeGlut first 🙂
$ sudo apt-get install freeglut3 freeglut3-dev

Ceate a new project and select the “GLUT project” in the project wizard.
An important tip: Say: /usr when it asks the “Please, Select GLUT’s location:”.

[ Note 2 ]
If you want to develope GLFW applications, install GLFW first ( )
Read also this posting…
The Ubuntu’s freeglut library is more up-to-date than GLFW.

[ Note 3 ], c-cpp-reference:
Do not forget to install the “c-cpp-reference” manuals.  Run this command:
$ sudo apt-get install c-cpp-reference

OR use your Synaptic Package Manager and get the package. It will put some help files in the /usr/share/doc/c-cpp-reference/ directory.
Start Firefox and point it to /usr/share/doc/c-cpp-reference/index.html

Also these C/C++ sites are very helpful:
LinuxTutorialC++.html  +’s book..

+ The ultimate collection of C++ tutorials  and C++ wikibook…
+ STL (Standard Template Library) guide   (couple of simple STL samples test-std1.cpp and test-std2.cpp )

[ Note 4 ], <nothing so far>

[ Note 5 ], Important GLUT / OpenGL guides:
Define OpenGL…
Read the note 1) first, then study  ( example: how to run the lessons…  on Linux ! )   Especially good source of programming guides !  ( Ubuntu games ) (GL Chronicles)  Simple Direct Media Layer (Excellent 2D library. Has also OpenGL support )   (….)
or try

GLUI = OpenGL based GUI library (buttons, edit boxes, list boxes etc…)

FTGL = Render text (fonts) in OpenGL

Animated OpenGL graphical UI  (Clutter, probably part of the upcoming GTK3)  (and Pigment)

OpenAL sound

Ubuntu gamers’ corner

[ Note 6 ], wxWidgets examples !

WxWidgets is a multi-platform GUI toolkit.

First, install the wx2.8-examples package
$ sudo apt-get install wx2.8-examples

The package puts the examples into /usr/share/doc/wx2.8-examples/examples/ directory. It’s a compressed tar-ball which you have to unpack/untar.

Run the “” script (in the same directory) to unpack the samples to your $HOME directory.
For example, run:
$ /usr/share/doc/wx2.8-examples/examples/   $HOME/wxwidgets2.8

And it will unpack & put the samples into your $HOME/wxwidgets2.8/samples/ folder.

You can now compile and run the examples directly from the command line.
The compilaton requires wxWidgets’ development headers and libraries. You will need these packages; libwxbase2.8-dev  wx2.8-headers  libwxgtk2.8-dev

As an example let’s compile the /popup sample code. First, move to the samples/popup/ directory
$ cd $HOME/wxwidgets2.8/samples/popup/

Compile the project.
$ make

Run it
$ ./popup
./  means the current directory. Yu must include it, otherwise the shell will not find the program, because by default, the current directory is NOT in the $PATH.
$ echo $PATH

Now, try to compile and run the other wxWidgets examples as well.

Study also the wxWidgets’ documentation package wx2.8-doc.
$ apt-cache search wx2.8-doc
wx2.8-doc – wxWidgets Cross-platform C++ GUI toolkit (documentation)

Install it and list the documentation (html) files
$ dpkg -L wx2.8-doc
$ dpkg -L wx2.8-doc | grep index
And then open the index.html in Firefox.

Of course, the documentation is available online too…
read  and…

[ Note 7 ], Necessary packages to develope SDL-applications.
Define SDL…   Homepage…

SDL stands for Simple DirectMedia Layer…
It’s a framework to greate portable 2D graphics applications. It also supports OpenGL.

First, list all packages that belong to the SDL family.
$ apt-cache search libsdl | grep dev
The “-dev” packages contain the header (include) files and dynamic libraries for app development. You’ll need them.

Install at least these basic packages. These give you a good start.
$ sudo aptitude install libsdl1.2-dev  libsdl-image1.2-dev  libsdl-sound1.2-dev  libsdl-mixer1.2-dev
However, the most basic apps need only the “libsdl1.2-dev”.

Then create a basic SDL-application via the Code::Blocks’ project wizard (select SDL project).

Note: The SDL’s sound, image and mixer functions have their own libraries and include files which you must add to your project.

And add these includes to your code:
#include <SDL_image.h>
#include <SDL_mixer.h>
#include <SDL_sound.h>

Additional information:
This command will list the installed SDL related packages
$ dpkg -l | grep libsdl

This command will list the installed SDL related libraries
$ ls -l  /usr/lib/libSDL*so

This command will list the available include files (most of them are included through the SDL.h)
$ ls -l /usr/include/SDL/*

This command (already in your project’s build options) finds the library PATH, library name and the include PATH + possible debug options.
All well done libraries have this xxx-config thing.
$ sdl-config –cflags –libs

[ Note 8 ], Make beautiful graphics with Cairo Graphics

MacSlow’s Cairo-Clock (a good example)

Study also: OpenVG.

[ Note 9 ], Gallium 3D, a new superior graphics engine for Unix/Linux

Study also: and
+ there’s some momentum to put Clutter… with its advanced graphics to the upcoming GNOME 3.0. Really nice.

[ Note 10 ], Programming with the Boost c++ library


[ Note 11 ], Other important programming resources:
Kernel, driver and module programmer’s heaven:

[ Note 12 ], Essential manual pages… that we developers often forget to install and use.

What manual pages does Ubuntu (or any other distro) offer?
$ apt-cache search manpages

manpages – Manual pages about using a GNU/Linux system
manpages-dev – Manual pages about using GNU/Linux for development
manpages-posix – Manual pages about using POSIX system
manpages-posix-dev – Manual pages about using a POSIX system for development

Install all manpages*dev packages
$ sudo apt-get install manpages-dev manpages-posix-dev

Note:  This command vill tell you what manual sections (1 – 8 ) the package covers.
$ apt-cache show manpages-posix-dev

Now search help:
$ man 3 fprintf
$ man sqrt
$ man pthread_create
$ man sem_init

$ man 3 socket
$ man 7 pthreads
$ man 7 sem_overview

Use also whatis and apropos commands (eg. to reveal the section number)
$ whatis pthread_create

$ apropos pthread_create
$ apropos pthread

[ Note 13 ], “How to become a real hacker” by Eric S. Raymond, updated 2008 version.

[ Note 14 ], A tip for zooming text in Code::Blocks IDE.
Press CNTR +  NUMPAD + or NUMPAD – keys to zoom the text.
NUMPAD +/- are tangents on the numerical keypad.

[ Note 15 ], Make your machine talk. YES TALK !
Define TTS, Text To Speech…


Simple examples using espeak:
$ espeak “Hi, Hi Joe. How are you today?”
$ echo “I beg your pardon, could you help me to find this address.” | espeak

$ echo “All your base are belong to us. Do you agree?” | espeak -v en-us -p 10 -s 140

Speak french
$ echo “Avez-vous un frère ou une soeur?” |  espeak -v fr 

One more example: Speak the “ls” command’s manual page, paragraphs NAME, DESCRIPTION and SEE ALSO.
$ zcat /usr/share/man/man1/ls.1.gz | nroff -man | col -b | sed -e ‘/./{H;$!d;}’ -e ‘x;/NAME/b’ -e ‘/DESCRIPTION/b’ -e ‘/SEE ALSO/b’ -e d | espeak -p 30 -s 135 -l 10 -v en+3

List available voices (languages)
$ espeak –voices
$ man espeak

Define Speech Recognition…
Study the The Julius voice recognition system and PerlBox voice commander
Writing a command and control application with Julius voice recognition…   PerlBox voice commander…

[ Note 16 ] ,77 useful Linux commands.…

[ Note 17 ],
Windows converts, read this:
All users, read the sticky threads:

[ Note 18 ],
Learn by studying the existing source code of applications in the Ubuntu distribution.
A real world example: How do I implement a code that can distinguish between real files and file links (symbolic and hard links)?
Answer: Study the source code of the “readlink” command.

But first, what package the readlink belongs to?
$ apt-cache search readlink
coreutils – it is. The GNU core utilities package.

[ Note: You must activate the source code repository in the Software Sources dialog. You will find it in the Administration menu. Activate or add the deb-src lines.
Refresh the package list in your pc (sudo apt-get update) ], then

Apt-get the source.
$ apt-get source coreutils
$ cd coreutils-6.10

Locate the “readlink” function and all places it’s been called from
$ grep -R readlink *

And study the code 😉

I took this example from

A second example.
I want to make some improvements to the GNOME’s Disk-Mounter applet. It’s an applet you have on the desktop panel.
Where’s the source?  Some digging reveals that the package name is “gnome-applets”.
Get the source.
$ mkdir -p $HOME/code &&  cd $HOME/code
$ apt-get source gnome-applets

$ cd gnome-applets-2.22.1/

Configure and compile with the normal mantra; ./configure && make
( It requires 5 or 6 dependencies if you want to compile all the applets)
The code of the Disk Mounter is in
$ cd drivemount

Make your changes and type “make” to recompile it.
Type “sudo make install” to install it.

Leave a Reply

Your email address will not be published. Required fields are marked *

nineteen − nine =

© All Right Reserved 2019-2020