c++ - Linux/Ubuntu 中的 OpenCV 安装

标签 c++ linux opencv ubuntu

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

我已经创建了一个名为 Workspace 的文件,我在其中创建了 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

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

最佳答案

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 中,可以轻松打开/关闭设置,例如是否构建示例...右侧的值列是可编辑的...如果您在底部点击按钮 Configure< 更改了 gui 中的设置 然后当它完成时点击 Generate 执行与正常 cmake .. 相同的操作,现在返回到上面的第 4 步进行编译

关于c++ - Linux/Ubuntu 中的 OpenCV 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29246757/

相关文章:

linux - 可以在不同的 CPU 内核上执行相同网络数据包的硬和软 IRQ 吗?

linux - docker-compose 不能使用 .env 中的变量

linux - 如何读取包含字符串的文件并在目录中找到它

matlab - 将 OpenCV 源代码编译到 Matlab

c++ - 使用可变目录在 C++ 中复制文件

c++ - VS2010 中令人困惑的 std::string::c_str() 行为

c++ - 将对象转换为数据类型?

c++ - imread 找不到图像

如果所有邻居都是背景,则 OpenCV 二元过滤器将像素设置为背景

opencv - 使用 Mathematica 的计算机视觉