簡體   English   中英

在 Linux/Ubuntu 中安裝 OpenCV

[英]OpenCV Installation in Linux/Ubuntu

我正在做這個教程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_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 中,它很容易切換開/關設置,例如是否構建示例...右側的值列是可編輯的...如果您更改了底部的 gui 中的設置點擊按鈕Configure然后當它完成點擊Generate到執行與普通cmake ..相同的操作cmake ..現在返回上面的第 4 步進行編譯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM