Muleque Muleque - 5 months ago 10
Linux Question

OpenCV Installation in Linux/Ubuntu

I am doing this Tutorial
But I got confused. I stopped at building the OpenCV from source.

I already created an File called Workspace where I made the cmake_binary_dir (named release). I downloaded the sourcefile (which is in my home directory and named: opencv-2.3.1), and now I want to run this


where I use:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/markus/opencv-2.3.1

But the Terminal keeps telling me, that this source directory does not exist!?
So what I am doing wrong?


CMAKE_INSTALL_PREFIX defines where to distribute the binary to after its compiled and linked, it defaults to good place (/usr/local/) so avoid defining it

You are leaving out the trailing .. in your cmake command which tells it where to get the source code hence the error message

Here are the typical steps when installing from source code any project which uses cmake

if you see a file :


in the src directory this indicates it wants you to use cmake

0  cd into dir where your expanded source code lives
1  mkdir build # make a build dir (initially empty)  
2  cd build
3  cmake .. # NOTE those little .. which declares relative path to src dir
      which says populate current dir (build) with compiled code 
      and get the source code and configs from parent directory (..)
4  examine the output, if it looks successful go to step 5
      if it has errors you may need to install upstream dependent 
      libraries then try cmake again 
5  make -j4  # compile source,  -j speeds up by using multicore
6  sudo make install <-- only if above step 4 and 5 are OK

You can do everything cmake related from command line, yet its GUI can be quite handy especially with an unfamiliar project. In above instead of typing :

cmake ..    

its GUI version is :

cmake-gui ..

in the GUI its easy to toggle on/off settings like to build examples or not ... the values column on the right is editable