Update to 2.0.0 tree from current Fremantle build
[opencv] / INSTALL
1 = OpenCV Installation Guide =
2
3 == Prerequisites ==
4
5 === Common Prerequisites ===
6
7   * C/C++ compiler (OpenCV is known to work with VS2005, VS2008,
8         including Express Editions, and Mingw on Windows,
9         GCC 4.x on Linux, MacOSX and other Unix-like systems).
10   * CMake 2.6 or later. CMake is now the only method of building OpenCV SVN snapshots
11     on Windows and the recommended method on Linux/MacOSX.
12   * (''Optional'') Subversion client (e.g. command-line svn tool, SmartSVN, Tortoise SVN) 
13   * (''Optional'') Python 2.5.x or 2.6.x (Python 3.x support status is unknown),
14     including the development files: Python.h, etc. in order to build Python wrappers
15   * (''Optional'') SWIG 1.3.30 or later to build Python & Octave wrappers
16     (in order to build Octave wrappers you will need at least SWIG 1.3.36).
17   * (''Optional'') IPP 5.1 or later. OpenCV does not require IPP, but can be configured to
18     use IPP to make some functions run faster.
19   * (''Optional'') LiveTeX distribution (or MiKTeX on Windows) to build the up-to-date OpenCV reference manual
20
21 === Extra Prerequisites (Linux/BSD/other Unix-like OSes) ===
22
23   * pkg-config. It is used at the configuration stage and also simplifies the further use of OpenCV itself.
24   * (''Optional'') gtk+ 2.x and the related packages (glib, gthread etc.).
25     This is the GUI toolkit of choice for highgui on OSes other than Windows and MacOSX.
26   * (''Optional'') libjpeg, libtiff, libjasper, libpng and zlib. Install any of those with the associated
27     development packages (libjpeg-dev etc. on Debian/Ubuntu) to be able to read/write the corresponding
28     image formats.
29   * (''Optional'') ffmpeg, libgstreamer, libxine, unicap, libdc1394 2.x (or libdc1394 1.x + libraw1394).
30     You should have some/all of these packages installed (together with associated development packages)
31     to add video capturing, video decoding and video encoding capabilities to highgui.
32     The output of the configure script or cmake will show you, which of the packages have been detected
33     and will be used in highgui. For example, on Ubuntu 8.10 all the necessary ffmpeg files
34     can be installed using the following command:
35         sudo apt-get install libavformat-dev libswscale-dev
36   * (''Optional'') Octave 2.9 or later, together with SWIG 1.3.36 or later, in order to build Octave wrappers.
37     Note that currently Octave wrappers can only be built with autotools, not cmake.
38
39 === Extra Prerequisities (MacOSX) ===
40
41   * Xcode 3.1 or later. It does not only include the required C++ compiler,
42     but also Quicktime and Carbon frameworks that make highgui on MacOSX functional.
43     Besides, CMake can generate Xcode projects, so you can
44     build OpenCV conveniently from within the IDE.
45
46 == Getting the latest stable OpenCV version ==
47
48   * Go to http://sourceforge.net/projects/opencvlibrary
49   * Windows: download the executable installation package for Windows and run it
50   * Linux/MacOSX/other operating systems: download the source tarball and unpack it
51
52 === Getting the cutting-edge OpenCV from SourceForge SVN repository ===
53
54   Launch SVN client and checkout either
55       a) the current OpenCV snapshot from here:
56          http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk
57       b) or the latest tested OpenCV snapshot from here:
58          http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/tags/latest_tested_snapshot
59
60   In Linux/MacOSX it can be done using command line, e.g.:
61     {{{
62     cd ~/<my_working_directory>
63     svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk
64     }}}
65
66 == Building OpenCV from source using CMake (Cross-platform) ==
67
68    1. Create a temporary directory, which we denote as <cmake_binary_dir>,
69       where you want to put the generated Makefiles,
70       VisualStudio, Xcode, or Eclipse etc. project files as well the object files and output binaries.
71       You can do it using CMake GUI.
72
73    2.
74      2a. If you use CMake GUI, execute "Configure" to do the initial configuration,
75       then adjust any options, then press "Configure" again and then press "Generate".
76       
77       For the best performance, and if you compiler and the platform supports it,
78       it is recommended to turn on SSE2 optimization
79       (on Mac and Windows it is turned on by default) and OpenMP support.
80       
81       Also, if you want to build Python wrappers, samples or the reference manual in PDF,
82       you should explicitly turn it on.
83
84      2b. If you are using command line, enter the <cmake_binary_dir> and type
85     {{{
86     cmake [<some optional parameters...>] <path to the OpenCV source directory>
87     }}}
88
89       For example, if you downloaded the project to ~/projects/opencv, you can do the following:
90     {{{
91     cd ~/projects/opencv # the directory containing INSTALL, CMakeLists.txt etc.
92     mkdir release
93     cd release
94     cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
95     }}}
96       that will generate makefiles for the Release configuration and will put them in
97       ~/projects/opencv/release directory.
98
99    3.
100      3a. If you generated project files for VisualStudio, Xcode, Eclipse etc., run the respective IDE, open
101          the OpenCV top-level project/solution/workspace etc. and build it.
102
103      3b. If you generated makefiles, then enter the created temporary directory and run make/nmake utility.
104          Then you can optionally run "sudo make install".
105
106    4. If you did not run "make install", you should let your system know where to find the generated libraries.
107
108       On Windows you should add <cmake_binary_dir>/bin/debug and <cmake_binary_dir>/bin/release to the system path
109       (My Computer--[Right button click]-->Properties->Advanced->Environment Variables->Path)
110
111       On Linux you should add <cmake_binary_dir>/lib[/debug|/release] to /etc/ld.so.conf or
112       to LD_LIBRARY_PATH, e.g.:
113     {{{
114     export LD_LIBRARY_PATH=~/projects/opencv/release/lib:$LD_LIBRARY_PATH
115     sudo ldconfig
116     }}}
117       On MacOSX you should add <cmake_binary_dir>/lib[/debug|/release] to DYLD_LIBRARY_PATH.
118   
119 == Testing OpenCV (CMake, cross-platform) ==
120
121   You may turn on "BUILD_EXAMPLES" in CMake GUI or run cmake with "-D BUILD_EXAMPLES=ON" option,
122   then it will include short demo samples to the build. Note that some of them need image files
123   from the original source directory, you may just copy them to the bin directory.
124
125   You can also run tests correctness tests <cmake_binary_dir>/bin[/debug|/release]/cxcoretest and .../cvtest.
126
127 === Testing Python/Octave wrappers ===
128
129   As long as you build Python/Octave wrappers and installed them, you can
130   just enter opencv/samples/swig_python or opencv/samples/octave and run the samples, e.g.
131     {{{
132     python delaunay.py
133     }}}
134
135 === Building your own code that uses OpenCV ===
136
137   * If you use CMake, you can write your own CMakeLists.txt script and use the provided FindOpenCV.cmake file there,
138     just like you would use FindJPEG.cmake etc. Please, refer to CMake documentation.
139   * You can add opencv include, lib and bin subdirectory to your IDE settings.
140   * For hand-written Makefiles you can specify the necessary paths and options manually, e.g.:
141     {{{
142     g++ -o my_example my_example.cpp -I<opencv_source_dir>/include[/opencv] \
143         -L<cmake_binary_dir>/lib -lcxcore -lcv -lcvaux -lhighgui -lml
144     }}}
145   * Finally, you can use pkg-config and the provided opencv.pc.
146      1. Make sure that opencv.pc is found by pkg-config:
147     {{{
148     pkg-config opencv --libs  # should print something like -lcxcore -lcv ...
149     }}}
150      2. You can now use it in your Makefiles or build scripts, e.g.:
151     {{{
152     g++ -o my_example my_example.cpp `pkg-config opencv --cflags --libs`
153     }}}
154 ----
155 Up-to-date version of this manual can be found here: http://opencv.willowgarage.com/wiki/InstallGuide
156
157 [[Welcome | OpenCV Wiki]]
158
159 [[FullOpenCVWiki | Full OpenCV Wiki]]