编译支持Contrib和C++11的OpenCV?

3
我想在Ubuntu 16.04上从源代码编译OpenCV。我以前已经成功地做过几次了。我正在按照pyimagesearch的教程进行操作。通常情况下,这很有效,但是这次对于contrib模块text,我遇到了以下错误:

[27%] Generating precomp.hpp.gch/opencv_text_RELEASE.gch In file

included from /usr/include/c++/5/cinttypes:35:0,

from /usr/local/include/tesseract/host.h:30, from /usr/local/include/tesseract/serialis.h:26, from /usr/local/include/tesseract/baseapi.h:37, from /home/rvq/github/opencv-3.2.0/build/modules/text/precomp.hpp:51:

/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support \ ^

[27%] Built target pch_Generate_opencv_saliency

请问有人知道如何解决这个问题吗?
1个回答

5

-D ENABLE_PRECOMPILED_HEADERS=OFF \添加到CMake命令中可以解决这个问题。

CMake命令完整内容:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_EXTRA_MODULES_PATH=~/github/opencv_contrib-3.2.0/modules \
    -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
    -D ENABLE_PRECOMPILED_HEADERS=OFF \
    -D BUILD_EXAMPLES=ON ..

@GuySoft 对我起作用的是将“-D BUILD_EXAMPLES=ON”设置为编译之前我尝试使用的“-D BUILD_EXAMPLES=OFF”。我不知道这些东西如何联系在一起,只是我的纯粹经验。 - Alex Ionescu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接