Linux / Ubuntu中的OpenCV安装

我正在做这个教程http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation但是我感到困惑。 我停止从源代码构buildOpenCV。

我已经创build了一个名为Workspace的文件,我在其中创build了cmake_binary_dir (名为release)。 我下载了源文件(这是在我的主目录,并命名为:opencv-2.3.1),现在我想运行这个

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

我在哪里使用:

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

但terminal一直告诉我,这个源码目录不存在!? 那么我做错了什么?

CMAKE_INSTALL_PREFIX定义了在编译和链接之后将二进制文件分发到哪里,它默认是很好的地方(/ usr / local /),所以不要定义它

你正在离开尾随..在你的cmake命令,告诉它在哪里得到的源代码,因此错误信息

以下是从源代码安装任何使用cmake的项目时的典型步骤

如果你看到一个文件:

 CMakeLists.txt 

在src目录中,这表示它希望你使用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 

你可以从命令行执行所有与cmake相关的操作,但是对于一个不熟悉的项目来说,它的GUI可以非常方便。 在上面而不是输入:

 cmake .. 

其GUI版本是:

 cmake-gui .. 

在GUI中,它很容易打开/关闭设置,如构建示例或不…右侧的值列是可编辑的