opencv3.4.2 ubuntu16.04安裝 error: ‘nullptr’ was not dec


最近需要用用opencv。在阿里雲服務器ubuntu16.04上安裝部署了下。

 

沒啥好說的,下載最新opencv-3.4.2 

文件准備

1.opencv-3.4.2.zip 
2. opencv_contrib-3.4.2.zip

(我是放在/home/myname/download/下)然后

wget https://github.com/Itseez/opencv/archive/3.4.2.zip

wget https://github.com/opencv/opencv_contrib/archive/3.4.2.zip

准備

先安裝以下依賴包

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 sudo apt-get install build-essential qt5-default ccache libv4l-dev libavresample-dev libgphoto2-dev libopenblas-base libopenblas-dev doxygen openjdk-8-jdk pylint libvtk6-dev sudo apt-get install pkg-config

1.解壓下載好的包:(我是放在/home/myname/download/下)然后

unzip opencv-3.4.2.zip unzip opencv_contrib-3.4.2.zip

2.解壓完后需要將opencv_contrib.zip提取到opencv目錄下,同時在該目錄下新建一個文件夾build:

cp -r opencv_contrib-3.4.2 opencv-3.2.2 #復制opencv_contrib到opencv目錄下 cd opencv-3.4.2 mkdir build #新建文件夾build

編譯

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.2/modules -D PYTHON_EXECUTABLE=/usr/bin/python3 -D BUILD_EXAMPLES=ON ..

 

make時出現錯誤:

 /usr/local/include/tesseract/baseapi.h: In member function ‘int tesseract::TessBaseAPI::Init(const char*, const char*)’:
/usr/local/include/tesseract/baseapi.h:235:50: error: ‘nullptr’ was not declared in this scope
     return Init(datapath, language, OEM_DEFAULT, nullptr, 0, nullptr, nullptr, false);
                                                  ^
/usr/local/include/tesseract/baseapi.h: In member function ‘Boxa* tesseract::TessBaseAPI::GetTextlines(Pixa**, int**)’:
/usr/local/include/tesseract/baseapi.h:413:51: error: ‘nullptr’ was not declared in this scope
     return GetTextlines(false, 0, pixa, blockids, nullptr);
                                                   ^
/usr/local/include/tesseract/baseapi.h: In member function ‘Boxa* tesseract::TessBaseAPI::GetComponentImages(tesseract::PageIteratorLevel, bool, Pixa**, int**)’:
/usr/local/include/tesseract/baseapi.h:464:75: error: ‘nullptr’ was not declared in this scope
     return GetComponentImages(level, text_only, false, 0, pixa, blockids, nullptr);
                                                                           ^
modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/build.make:62: recipe for target 'modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/opencv_text_pch_dephelp.cxx.o' failed
make[2]: *** [modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/opencv_text_pch_dephelp.cxx.o] Error 1
CMakeFiles/Makefile2:13717: recipe for target 'modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/all' failed
make[1]: *** [modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
 
 
原因是C11選項未打開。修改
 opencv-3.4.2目錄下面CMakeLists.txt 參考上圖,添加一行即可。從新CMake


然后 編譯:
make
然后:
sudo make install

完事!

打賞:

 




 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM