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.
See: http://lgp203.free.fr/spip/spip.php?article1
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 http://lgp203.free.fr/ubuntu/ hardy universe
The packages are signed with a security key. Add this public key to your package system. Run this command
$ wget -q http://lgp203.free.fr/public.key -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 ( http://glfw.sourceforge.net/ )
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:
http://www.cppreference.com
+
http://www.cplusplus.com
+
LinuxTutorialC++.html + Informit.com’s book..
+ The ultimate collection of C++ tutorials
http://ubuntuforums.org/showthread.php?t=333867#2 and C++ wikibook…
+ STL (Standard Template Library) guide
http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html (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
http://www.opengl.org/code/category/C19/
http://nehe.gamedev.net ( example: how to run the lessons… on Linux ! )
http://ubuntuforums.org/showthread.php?t=333867#8 Especially good source of programming guides !
http://www.gamedev.net
http://www.glprogramming.com
http://ubuntu-gamedev.wikispaces.com ( Ubuntu games )
http://www.glchronicles.mccolm.org (GL Chronicles)
http://www.libsdl.org Simple Direct Media Layer (Excellent 2D library. Has also OpenGL support )
http://lazyfoo.net/SDL_tutorials/index.php (….)
or try
http://g2.sourceforge.net/
—
GLUI = OpenGL based GUI library (buttons, edit boxes, list boxes etc…)
http://glui.sourceforge.net
FTGL = Render text (fonts) in OpenGL
http://homepages.paradise.net.nz/henryj/code/#FTGL
Animated OpenGL graphical UI
http://clutter-project.org (Clutter, probably part of the upcoming GTK3)
https://code.fluendo.com/pigment/trac (and Pigment)
OpenAL sound
http://www.openal.org
Ubuntu gamers’ corner
http://ubuntu-gamedev.wikispaces.com/
[ 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 “unpack_examples.sh” script (in the same directory) to unpack the samples to your $HOME directory.
For example, run:
$ /usr/share/doc/wx2.8-examples/examples/unpack_examples.sh $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 http://zetcode.com/tutorials/wxwidgetstutorial and http://en.wikibooks.org/wiki/…
[ 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
http://cairographics.org/samples/
MacSlow’s Cairo-Clock (a good example)
http://macslow.thepimp.net/?page_id=23
Study also: OpenVG.
[ Note 9 ], Gallium 3D, a new superior graphics engine for Unix/Linux
Study also: http://zrusin.blogspot.com and http://aseigo.blogspot.com
+ 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
Study: http://ubuntuforums.org/#post5164645
Boost.org
[ Note 11 ], Other important programming resources: http://www.futuredesktop.org/opportunities.html
Kernel, driver and module programmer’s heaven: http://www.futuredesktop.org/kernel.html
[ 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.
http://www.catb.org/~esr/faqs/hacker-howto.html
[ 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…
Read: http://ubuntuforums.org/showthread.php?t=291919
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.
http://searchenterpriselinux.techtarget.com/…
[ Note 17 ],
Windows converts, read this: http://ubuntuforums.org/showthread.php?t=554070
All users, read the sticky threads: http://ubuntuforums.org/forumdisplay.php?f=39
[ 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 Ubuntuforums.org
——————-
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.