【问题标题】:OpenCV Installation in Linux/UbuntuLinux/Ubuntu 中的 OpenCV 安装
【发布时间】:2015-05-28 14:21:09
【问题描述】:

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

我已经创建了一个名为 Workspace 的文件,并在其中创建了 cmake_binary_dir(命名版本)。我下载了源文件(在我的主目录中并命名为: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-gui 以便您可以看到所有选项集。尽管此答案是为 mac os x 编写的,但在 ubuntu 上应该没有太大不同,因为它是 cmake stackoverflow.com/questions/19671827/…
  • 不要离开.. ?

标签: c++ linux opencv ubuntu


【解决方案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 进行编译

【讨论】:

    猜你喜欢
    • 2014-12-22
    • 1970-01-01
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-01
    • 2015-12-21
    • 1970-01-01
    相关资源
    最近更新 更多