24 May 2011

Setting up Xerces XML parsing library in ubuntu

The Apache project's Xerces-C libraries support the DOM approach to XML parsing. The entire XML file is imported into memory and the data is held as nodes in a data tree which can be traversed for information.

The Xerces-C C++ parser home page: http://xml.apache.org/xerces-c/

1. Go to your working directory.
2. Download the compressed file from here
3. Unpack the downloaded file: tar -xzf xerces-c-3.0.1.tar.gz
4. Go to unpacked directory: cd xerces-c-3.0.1
5. ./configure --prefix=/opt
6. Build: make
7. Install: sudo make install     

This will install development files such as include header files and libraries in "/opt" so compiler flags and linker flags are required:
  • Compiler flags: -I/opt/include
  • Linker flags: -L/opt/lib -lxerces-c 
 Compiling a sample program named parser.cpp - 
g++ -g -Wall -pedantic -I/opt/include -L/opt/lib -lxerces-c parser.cpp -DMAIN_TEST -o parser 

Get the complete program from - 

Useful Links - 
1. http://xerces.apache.org/xerces-c/
2. http://xerces.apache.org/xerces-c/api-2.html
3. http://www.yolinux.com/TUTORIALS/XML-Xerces-C.html
4. http://en.wikipedia.org/wiki/Xerces
5. http://www.artima.com/cppsource/xml_data_binding.html

23 May 2011

Installation instructions for GALib on Ubuntu

Download the current version of GALib from here.

Extract it in your home folder and go to that folder from terminal.

Edit the file 'makevars'. This file contains the compiler flags that are unique for each cpu/os/compiler, as well as the destination directory for doing 'make install'.

To build the library and the non-graphic examples:
% make
To install GAlib on your system:
% make install

20 May 2011

Setting up GAUL(Genetic Algorithm Utility Library) on Ubuntu

Instructions for installation from source code -

1. Download GAUL library from here. There are some example programs available
    on the same site. You can download them for testing and using different            
    functionalities of GAUL.

2. If you want to enable the S-Lang and OpenMPI functionality of GAUL, then
    install the openmpi library first and slang library. SLang can be downloaded
    from here.

    For compiling slang, extract the compressed file in your home folder and type
    these commands  -
    $ cd slang-2.1.4
    $ ./configure
    $ make
    $ sudo make install

3. Now extract the GAUL compressed files into your home folder and go into that
    folder and type the following commands -
    $ cd gaul-devel-0.1850-0
    In its simplest form, compilation is achieved by typing:
$ ./configure && make
    Or, if you don't have S-Lang installed - type:
$./configure --enable-slang=no && make

    Two additional configuration options that you may find useful are:
$ ./configure --enable-efence=yes # Link with the electric fence malloc debugger.
$ ./configure --enable-mpi=yes    # Link with the MPI message passing libraries 
for parallel code
4. Finally type -
$ sudo make install
5. Now open the .bashrc file from you home directory and add the following line to it.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
6. For compiling any program with gaul libraries, use the following linkers - 
-lgaul -lgaul_util -lm 
Eg: - gcc test_utils.c -lgaul -lgaul_util -lm 

18 May 2011

Installing Open RAVE on Ubuntu

Install from the package manager

Type these commands in the terminal -  
sudo add-apt-repository ppa:openrave/release
sudo apt-get update
sudo apt-get install openrave

Compile From Sources

Get latest stable source code (constantly updated):
svn co https://openrave.svn.sourceforge.net/svnroot/openrave/tags/latest_stable openrave
Visit OpenRAVE

Open MPI on Ubuntu

A. Install OpenMPI

$ sudo apt-get install libopenmpi-dev openmpi-bin openmpi-doc
$ sudo apt-get install ssh

B. Configure SSH

$ ssh-keygen -t dsa
$ cd ~/.ssh
$ cat id_dsa.pub >> authorized_keys

C. MPI Program Example

Filename: MPI_Hello.c

#include <stdio.h>
#include <mpi.h>

int main(int argc, char** argv) 
    int myrank, nprocs;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    printf("Hello from processor %d of %d\n", myrank, nprocs);

    return 0;

D. Compilation

$ mpicc MPI_Hello.c -o MPI_Hello

E. Execution

$ mpiexec -n 5 MPI_Hello

F. Integrated Development Environment

We will use Geany as an IDE to make compilation process easier and faster. To compile MPI program with Geany, follow these steps:
  1. Install Geany.
    $ sudo apt-get install geany
  2. Download MPI tags file and copy to ~/.config/geany/tags/
    $ wget http://auriza.site40.net/docs/paralel/openmpi.c.tags
    $ cp openmpi.c.tags ~/.config/geany/tags/
  3. Start Geany, and write MPI program example above.                                             
  4. Compilation setting: Build - Set Includes and Arguments.
    Compile: mpicc -Wall "%f" -o "%e"                                                                  Execute: mpiexec -n 5 "%e"
   5.To compile program: click Compile
   6. To execute program: click Execute.


17 May 2011

Installing ROS (Diamondback) on Ubuntu

If you need to install from source, please see source (download-and-compile) installation instructions.
  1. Ubuntu install of Diamondback
    1. Installation
      1. Configure your Ubuntu repositories
      2. Setup your sources.list
      3. Set up your keys
      4. Installation
      5. Environment setup
    2. Tutorials


Configure your Ubuntu repositories

Configure your Ubuntu repositories to allow "restricted," "universe," and "multiverse." You can follow the Ubuntu guide for instructions on doing this.

Setup your sources.list

Setup your computer to accept software from ROS.org.
  • Ubuntu 10.04 (Lucid)
    • sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu lucid main" > /etc/apt/sources.list.d/ros-latest.list'
    Ubuntu 10.10 (Maverick)
    • sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu maverick main" > /etc/apt/sources.list.d/ros-latest.list'

Set up your keys

  • wget http://packages.ros.org/ros.key -O - | sudo apt-key add -


Make sure you have re-indexed the ROS.org server:
  • sudo apt-get update
There are many different libraries and tools in ROS. We provided four default configurations to get you started. You can also install ROS stacks individually.
  • Desktop-Full Install: (Recommended): ROS, rx, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception
    • sudo apt-get install ros-diamondback-desktop-full

    Desktop Install: ROS, rx, rviz, and robot-generic libraries
    • sudo apt-get install ros-diamondback-desktop

    ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
    • sudo apt-get install ros-diamondback-ros-base

    Individual Stack: You can also install a specific ROS stack (replace underscores with dashes of the stack name):
    • sudo apt-get install ros-diamondback-STACK
      sudo apt-get install ros-diamondback-slam-gmapping

Environment setup

It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

echo "source /opt/ros/diamondback/setup.bash" >> ~/.bashrc
. ~/.bashrc

If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.

If you just want to change the environment of your current shell, you can type:
source /opt/ros/diamondback/setup.bash

Now if you are setting ROS for localhost then add these two lines to bashrc file.
export ROS_MASTER_URI=http://localhost:11311 
export ROS_HOSTNAME=localhost

15 May 2011

Setting up Rhodes on Ubuntu 10.04

You guys must be having ubuntu 10.04 and above
installed. This command will help you to install rhomobile packages

type the following commands
$sudo apt-get install openjdk-6-jdk;
$sudo apt-get install ruby;
$sudo apt-get install rails;
$sudo apt-get install rubygems1.8;
$sudo gem install rails -V;
$sudo gem install templater -V;
$sudo gem install rhodes -V;

after these just locate where rhodes-2.*.*  is there ......
it will be in /var/lib/gems/1.8/gems/

now type this command....
$export PATH=$PATH:"/var/lib/gems/1.8/gems/rhodes-2.2.6/bin"

download android sdk and ndk from here:

SDK:   http://developer.android.com/sdk/index.html
NDK:   http://developer.android.com/sdk/ndk/index.html

now extract both in your home folder and type (basically go to tools
 $cd android-sdk-linux_86
$cd tools
$./android      (execute the emulator see if there are any

now type this command:

(on typing this you will have to give the jdk,android sdk and ndk
path only)

 $ JDK path: /usr/lib/jvm/java-6-openjdk/

 $ Android SDK path: /home/[pc-name]/<android_sdk_r07-linux_x86>/

<android_sdk_r07-linux_x86>  is the android-sdk folder name

 $ Android NDK path: /home/[pc-name]/<android_ndk_r5>/

<android_ndk_r5>  is the android ndk folder name

   * the remainder of the questions related to Windows and
Blackberry: (left blank)

now type :

$rhogen app store

(here store is your application name)

now type:

$cd store

and now type:

$rake -T

(gives a list of commands)


$rake run:android

now grab a cup of coffee and wait for three minutes  :D

any problems with installation you can post here....

OpenCV in Android

Using OpenCV in Android. This tutorial is tested under Ubuntu 10.04 + Android SDKr07 + Android NDKr4b.

Preparing the development environment

  • Download and install Android SDK. Details can be found here
  • Download eclipse and install the ADT plugin. Details can be found here
  • Download Androdi NDK. This tool is used to cross compile OpenCV source code to Android. Currently (NDK r4) only C is fully supported, so I can only use OpenCV 1.1 under Android. The laterst version of OpenCV uses lots of STL functions. 

Create the test project

  • Create a new Android project in eclipse. For example, called testOpenCV. Name the package name as: edu.stanford.android.
  • In the root directory of the project, create a new folder called jni and extract all files in android_opencv.tar.gz to this folder.
  • Run “$NDK/ndk-build” from your project directory. It will generate libopencv.so in the libs/armeabi folder.
  • Write Java code to use OpenCV functions. I have three java files which can be downloaded here. They are a little bit long so I do not want to paste the source code here. The general idea is that I use the intent to start the camera or gallery activities to get the image and send this image to OpenCV. After OpenCV finishes extracting SURF features, it send the processed image back to JVM. The interface between JVM and OpenCV is pretty simple: setSourceImage and getSourceImage.

Run the program

  • Press the menu button to select your camera to capture an image. The down-sampled image is saved in your gallery. Press the menu button again to select it from your gallery and features are automatically extracted.
  • Notice: if you select a large image in the gallery, the program may crash due to limited memory.
  • On my DROID phone, it usually takes 4 seconds to extract features from one image.

Set up GIT on Linux

First: Download and Install GIT
At the heart of GitHub is an open source version control system (VCS) called Git*. Created by the same dudes that created Linux, Git is responsible for everything GitHub related that happens locally on your computer.
i) Download and install the latest version of Git with Synaptic.
   We suggest you install git-core, git-gui, and git-doc.
When you’ve selected git-core, git-gui, and git-doc, hit “Apply” to install them.
If you don’t have a package manager like Synaptic, or you’d rather install the necessary git components from the command line, you can alternatively run the script below:
$ sudo apt-get install git-core git-gui git-doc

Next: Set Up SSH Keys

We use SSH keys to establish a secure connection between your computer and GitHub. Setting them up is fairly easy, but does involve a number of steps.
To make sure you generate a brand new key, you need to check if one already exists. First, you need to open an app called Terminal.
i) Check for SSH keys. Have an existing key pair? You can skip to Step 4.
First, we need to check for existing ssh keys on your computer:
$ cd ~/.ssh
If it says “No such file or directory“ skip to step 3. Otherwise continue to step 2.
ii) Backup and remove existing SSH keys.
Since there is already an SSH directory you’ll want to back the old one up and remove it:  
$ lsLists all the subdirectories in the current directoryconfig id_rsa id_rsa.pub known_hosts$ mkdir key_backupmakes a subdirectory called "key_backup" in the current directory$ cp id_rsa* key_backupCopies the contents of the id_rsa directory into key_backup
$ rm id_rsa*
iii) Generate a new SSH key.
To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.
$ ssh-keygen -t rsa -C "your_email@youremail.com"Creates a new ssh key using the provided emailGenerating public/private rsa key pair.
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):<press enter>
Press enter until you get this screen  - 
Your identification has been saved in /Users/your_user_directory/.ssh/id_rsa.Your public key has been saved in /Users/your_user_directory/.ssh/id_rsa.pub.The key fingerprint is:01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db user_name@username.comThe key's randomart image is:+--[ RSA 2048]----+|     .+   +      ||       = o O .   ||        = * *    ||       o = +     ||      o S .      ||     o o =       ||      o . E      ||                 ||                 |
iv) Add your SSH key to GitHub.
On the GitHub site Click “Account Settings” > Click “SSH Public Keys” > Click “Add another public key”
Open the id_rsa.pub file with a text editor (Notepad, TextEdit, or gedit will do just fine). This is your public SSH key. You may need turn on “view hidden files” to find it because the .ssh directory is hidden. It’s important you copy your SSH key exactly as it is written without adding any newlines or whitespace.Now paste it into the “Key” field.
Now paste it into the “Key” field.
Hit “Add Key.”
v) Test everything out.
To make sure everything is working you’ll now SSH to GitHub. Don’t change the “git@github.com” part.That’s supposed to be there.
$ ssh git@github.com
Which should give you this:
The authenticity of host 'github.com (' can't be established.RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)?
PTY allocation request failed on channel 0 Hi username! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.

Then: Set Up Your Info

i) Set your username and email.

Git tracks who makes each commit by checking the user’s name and email. In addition, we use this info to associate your commits with your GitHub account. To set these, enter the code below, replacing the name and email with your own. The name should be your actual name, not your GitHub username.
$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@youremail.com"
ii) Set your GitHub token.

Some tools connect to GitHub without SSH. To use these tools properly you need to find and configure your API Token.
On the GitHub site Click “Account Settings” > Click “Account Admin.”
At the command line run the following code, using your GitHub username and token in place of the ones show
$ git config --global github.user username
$ git config --global github.token 0123456789yourf0123456789
*Note* If you ever change your GitHub password, a new token will be created and will need to be updated.

8 May 2011

Setting, Changing And Resetting MySQL Root Passwords

This tutorial explains how you can set, change and reset (if you've forgotten the password) MySQL root passwords. Time and again I see problems like mysqladmin:  connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'. So I thought it's time to remind you how to solve MySQL related password problems. If you are just looking for a quick fix how to reset a MySQL root password you can find that at the bottom of this tutorial.

Method 1 - Set up root password for the first time

If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To set up a root password for the first time, use the mysqladmin command at the shell prompt as follows:

  $ mysqladmin -u root password newpass
If you want to change (or update) a root password, then you need to use the following command:
$ mysqladmin -u root -p oldpassword newpass
Enter password:
If you get...
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
then follow the instructions below on how to recover your MySQL password.

Change MySQL password for other users

To change a normal user password you need to type:
$ mysqladmin -u user-name -p oldpassword newpass

Method 2 - Update or change password

MySQL stores usernames and passwords in the user table inside the MySQL database. You can directly update a password using the following method to update or change passwords:
1) Login to the MySQL server, type the following command at the shell prompt:
$ mysql -u root -p
2) Use the mysql database (type commands at the mysql> prompt):
mysql> use mysql;
3) Change password for a user:
mysql> update user set password=PASSWORD("newpass") where User='ENTER-USER-NAME-HERE';
4) Reload privileges:
mysql> flush privileges;
mysql> quit
This method you need to use while using PHP or Perl scripting.

Recover MySQL root password

You can recover a MySQL database server password with the following five easy steps:

Step # 1: Stop the MySQL server process.
Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for a password.
Step # 3: Connect to the MySQL server as the root user.
Step # 4: Set a new root password.
Step # 5: Exit and restart the MySQL server.

  Here are the commands you need to type for each step (log in as the root user):
Step # 1 : Stop the MySQL service:
# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.
Step # 2: Start the MySQL server w/o password:
# mysqld_safe --skip-grant-tables &
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step # 3: Connect to the MySQL server using the MySQL client:
# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Step # 4: Set a new MySQL root user password:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
Step # 5: Stop the MySQL server:
# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+  Done                    mysqld_safe --skip-grant-tables
Start the MySQL server and test it:
# /etc/init.d/mysql start
# mysql -u root -p

Setting MySql root password after installation

Generally if the password for MySql is not set during the installation, then these commands will help you set it externally.
It is also useful when it shows error -
"ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO"

/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysqld stop
/etc/init.d/mysqld start       

Installing Apache2 with PHP5 and MySQL Support on Ubuntu 10.10(LAMP)

1. Introduction

In this tutorial I use the hostname server1.example.com with the IP address These settings might differ for you, so you have to replace them where appropriate.
I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

             sudo su

2 Installing MySQL 5

First we install MySQL 5 like this:

sudo apt-get install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword

3 Installing Apache2

Apache2 is available as an Ubuntu package, therefore we can install it like this:
aptitude install apache2
Now direct your browser to, and you should see the Apache2 placeholder page (It works!):

Apache's default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.

4 Installing PHP5

We can install PHP5 and the Apache PHP5 module as follows:
sudo apt-get install php5 libapache2-mod-php5
We must restart Apache afterwards:
/etc/init.d/apache2 restart

5 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.
vi /var/www/info.php

Now we call that file in a browser (e.g.

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.

6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:
aptitude search php5

Pick the ones you need and install them like this:
sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

Now restart Apache2:
/etc/init.d/apache2 restart

Now reload in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:

7 phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it:
sudo apt-get install install phpmyadmin
You will see the following questions:
Web server to reconfigure automatically: <-- apache2
Configure database for phpmyadmin with dbconfig-common? <-- No
Afterwards, you can access phpMyAdmin under

Useful Links -

5 May 2011

Setting Android SDK on Ubuntu 10.10

Setting up the SDK is easy on Linux. It's getting the supporting tools installed that is the PITA. Here's one way to get it done. This is geared to the Ubuntu user, but it's the same method for all distros.

Running as root -- yes, there is a portion of this guide that has you run commands as root. This is a bad practice, but to make the guide simpler and more universal, it's necessary in this case. Just remember, when you're running as root, you can really screw things up.

Step One -- 32-bit libraries and headers
If you're using a 32 bit version of Linux, be aware that building from the AOSP tree is no longer supported after version 2.2.2. Most modern processors will run (and benefit) from using a 64-bit version of Linux, so upgrading is something worth considering.
If you are using a 64-bit version of Linux, you'll need to install the 32-bit versions of some libraries, as they aren't installed by default. If you are using Ubuntu 10.10, open your terminal and install them like so:

sudo apt-get install ia32-libs

Step Two -- Java 6
The SDK almost works with open Java alternatives, but almost doesn't cut it. We need to install Oracle's closed source version of the Java Development Kit and Runtime Environment. Since it's closed source, it's not available by default in the Ubuntu package manager. These commands will add a repository to your apt source list that keeps the Linux version of Sun Java up to date and available, then install what's needed.

 sudo apt-get install openjdk-6-jre openjdk-6-jre-headless

Step Three -- download the SDK

Download the Android SDK for Linux (http://dl.google.com/android/android-sdk_r08-linux_86.tgz). Open the archive, and extract the entire android-sdk-linux_86 folder into your home folder.

Step Four -- Setup the path for SDK
Now that you have it installed, you need to tell your shell where it is. Open your ~/.bashrc file and add it to your PATH. Here's a copy/paste method using vim -

    vim ~/.bashrc
Paste code:
PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH

press (Esc :wq) to save and exit

Now you need to refresh your shell. Enter this at the prompt:
cd ~/android-sdk-linux_86/tools/

On the left, choose Available packages.
Check the box that says Android Repository, then choose to install selected.
Choose Accept all and Install.

This take a few minutes, as it downloads everything you will ever need. If you want, you can choose to only install the tools and platform tools in your choice above.

Step five -- testing
On Ubuntu systems, adb has to run as root, or your device needs permission to communicate declared in the udev rules. You really should set up the udev rule for your phone and not run as root. In the meantime, you will need to restart adb as root each time your reboot or stop adb. Do it like so:
sudo su
cd /home/<username>/android-sdk-linux_86/platform-tools
./adb kill-server
./adb start-server

Next, make sure USB debugging is enabled on your phone, and connect it to a full speed USB port, one that's not on a hub. Sometimes hubs and front ports work fine. Sometimes they don't. Use the right ones to test, and try others later once you know it all works. After it's connected go back to the terminal:

cd ~/android-sdk-linux_86/platform-tools
./adb devices

You should see a serial number. That means it worked. Now try:
cd ~/
adb devices

You should see the same thing. This means your PATH was set-up right. And you're done. If you hit any snags, post away and we'll try to fix them.

Setting up OpenCV 2.2 on Ubuntu 10.10

Building and installing OpenCV 2.2 on Ubuntu 10.10.

1. First, install the dependencies from the repositories:
 sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev 

2.  Download the source code:
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.2/OpenCV-2.2.0.tar.bz2

3. Extract, create the build directory:
tar xfv OpenCV-2.2.0.tar.bz2
rm OpenCV-2.2.0.tar.bz2
cd OpenCV-2.2.0
mkdir opencv.build
cd opencv.build

4. Configure, make and install:
 cmake ..
 sudo make install

5. To configure the library, edit the following file (might be empty):

sudo gedit /etc/ld.so.conf.d/opencv.conf
and add the line

6. Then run:
sudo ldconfig

7. Edit the file:
sudo gedit /etc/bash.bashrc
and add the following lines at the PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

8. Now, edit the file:
sudo gedit ~/.bashrc
and add the following lines at the end:
export LD_LIBRARY_PATH=/home/<username>/OpenCV-2.2.0/lib
export PKG_CONFIG_PATH=/home/<username>/OpenCV-2.2.0/lib/pkgconfig

9. To check the path where opencv & other lib files are stored, do:

    $ pkg-config --cflags opencv
(output will come as)

    $ pkg-config --libs opencv
(output will come as)
-lcxcore -lcv -lhighgui -lcvaux -lml

These paths are needed to compile your opencv programs, as given in the next step.

10. To compile & run:

    $ g++ -I/usr/include/opencv -lcxcore -lhighgui -lm hello.cpp
    $ ./a.out <image name>

11. Now lets simplify the above big command by making a shortcut for it:
go to your local home directory(cd /home/) and open the .bashrc file using gedit(the file will be hidden). Append the following to the file:

    alias gcv="g++ -I/usr/include/opencv -lcv -lcxcore -lcvaux -lhighgui -lm"

and save. Close the terminal and open it again.(as this process requires relogin of the terminal)

12. Now, go to directory containing a sample program & do

    $ gcv filename.c && ./a.out
    $ gcv filename.c
    $ ./a.out input_img.jpg

As you can see the commands now become similar to $cc filename.c, $./a.out which are used normally for compiling and executing C programs.

13. Check whether all lib files are installed-
$ apt-cache search opencv
libcv-dev - development files for libcv
libcv0.9-0c2 - computer vision library
libcvaux-dev - development files for libcvaux
libcvaux0.9-0c2a - computer vision extension library
libhighgui-dev - development files for libhighgui
libhighgui0.9-0c2 - computer vision GUI library
opencv-doc - OpenCV documentation and examples
14. Sample testing code:
#include < opencv/cv.h >  /* required to use OpenCV */
#include < opencv/highgui.h > /* required to use OpenCV's highgui */
#include < stdio.h >
        int main(int argc, char *argv[])
           IplImage* img=0;                  /* pointer to an image */
           if(argv[1] != 0)
             img = cvLoadImage(argv[1], 0); // 1 for color
             printf("Enter filename\n");
           if(img != 0)
                cvNamedWindow("Display", CV_WINDOW_AUTOSIZE); // create a         window
                cvShowImage("Display", img); // show image in window
                cvWaitKey(0); // wait until user hits a key
               printf("File not found\n");
            return 0;