Installing OpenCV Under Linux
As far as I can tell it is possible to install OpenCV without
root access, but it's slightly more complicated. If you have root access
then su now and ignore any of the instructions in italics.
I downloaded version 0.9.7. If you use a later one, just substitute
your version number where it appears.
-
If (and only if) you downloaded OpenCV from sourceforge, decompress
the tarball and change to the new directory:
      tar xvzf opencv-0.9.7.tar.gz
      cd opencv-0.9.7 -
NON-ROOT ONLY: Create a new folder somewhere you have access to - the
desktop or your home folder are good places - and try to give the folder
a suitable name, something that will help you identify it at a later date.
(For the sake of continuity I will use /home/opencv/ in all examples on
this page. Simply substitute your directory for that one.)
Then type:
      ./configure --prefix=/home/opencv --enable-apps --with-gnu-ld --with-x -
ROOT ONLY: Configure the installation:
      ./configure --prefix=/home/intel/opencv-0.9.7 --enable-apps --with-gnu-ld --with-x -
Assuming all goes well, the configuration program will end with a prompt
to 'make'. Do that and then register the libraries (make install).
      make
      make install -
Copy the documentation from your decompressed folder to the folder made
during configuration.
NON-ROOT:       cp -R docs/  /home/opencv/
ROOT:       cp -R docs/ /home/intel/opencv-0.9.7/ -
ROOT ONLY: If you wish to do so at this point, a simlink can be handy
when updating to new versions and builds. (A simlink is a virtual link
to somewhere, essentially creating another way of referring to it.) If
you want to put one in, first change directory to the installation's
parent folder. For root users this will be /home/intel/.
Then use:
      ln -s opencv-0.9.7 opencv
The next time you update to a newer version of OpenCV, simply do the same but substituting the new folder name/version number. Provided you have used the simlink in paths then all your programs should still work, regardless of what version you're using. -
ROOT ONLY: You need to add a line to a config file so that linux knows
where to find the new libraries, so open '/etc/ld.so.conf' in your
favourite text editor and add '/home/intel/opencv/lib' to the end of the file
(or '/home/intel/opencv-0.9.7/lib' without the simlink). Then use the command:
      ldconfig -v
(If linux can't find ldconfig you get an error, in which case you can type 'locate ldconfig' and use the path it gives you.) -
Finally, you will need to add a line to your shell's rc file (e.g.
.bashrc, .cshrc, etc):
      cd ~
      vi .bashrc
As you'll notice, my system uses the bash shell. If yours uses csh then you'll need to use 'setenv' instead of 'export' below, but if you encounter problems then it may be because you need to use a slightly different syntax, in which case I recommend doing a quick google search for the proper way to set an environment variable in your shell. Once in vim, add or append the following:
      export LD_LIBRARY_PATH=/home/opencv/lib
      export PKG_CONFIG_PATH=/home/opencv/lib/pkgconfig
If this doesn't work, don't worry - I've added an extra bit in the Makefile which should get around the problem another way.
