ubuntu親測安裝opencv和成功解決Makefile:160: recipe for target 'all' failed make: *** [all] Error 2
阿新 • • 發佈:2020-12-07
1.因為專案需要,我安裝的是opencv3.0.0,從github上面下載的opencv包
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git #opencv_contrib可以省略,不過安裝上更全,有足夠的時間的話,建議安裝.
兩個都下載完以後,將opencv_contrib放到opencv資料夾下面,並安裝依賴項:
sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
將上面依賴性安裝成功以後,進入到opencv目錄下,在終端輸入命令
mkdir build;
cd build;
接下來就可以準備編譯了.
cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
報了這樣的錯誤Makefile:160: recipe for target 'all' failed make: *** [all] Error 2
網上說存在一些衝突因為我電腦裝了anaconda,所以換條命令:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_SHARED_LIBS=OFF -D WITH_OPENMP=ON -D ENABLE_PRECOMPILED_HEADERS=OFF ..
這樣就成功了...
接下來執行make -j8或make -j4
編譯完畢之後執行 sudo make install
以後步驟就完成了.僅供大家參考