ubuntu14.04安装opencv3.0遇到的问题

下载opencv3.0源码,解压到/home/username/softeware中,然后运行使用cmake-gui,开始有针对性的配置opencv,添加支持build_TBB, build_TFF, with_ TFF, with_TBB

1.关于支持QT

不要选择添加with_QT,因为这样默认支持的是qt4

2.关于报错

编译时,出现以下报错:

/home/usrname/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error:‘NppiGraphcutState’ has not been declared typedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppStat


解决办法:
需要修改源码,在path/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp中将
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
改为
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)


3.关于添加TBB出现以下错误

libopencv_imgproc.so.3.0.0: undefined reference to `tbb::task_group_context:

解决办法参考:这里github上的解决方案
即:
在path/opencv-3.0.0/3rdparty/tbb/CMakeLists.txt 中的215行
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
string(REPLACE "-Werror=non-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

后面添加以下代码:
# filter out flags that are not handled well by the TBB code
foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
string(REPLACE "-Werror=non-virtual-dtor" "" ${var} "${${var}}")
string(REPLACE "-fvisibility=hidden" "" ${var} "${${var}}")
string(REPLACE "-fvisibility-inlines-hidden" "" ${var} "${${var}}")
endforeach()

然后重新用cmakelists-gui进行configure和gernate
然后进入build文件夹中进行make即可

4.关于编译opencv工程,提示以下错误:

CMake Warning at /home/xxx/opencv-3.0.0/cmake/OpenCVConfig.cmake:153 (message):
Found OpenCV 3.0.0 Windows Super Pack but it has not binaries compatible
with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
Call Stack (most recent call first):
src/mrcimg/CMakeLists.txt:7 (find_package)
CMake Error at src/mrcimg/CMakeLists.txt:7 (find_package):
Found package configuration file:
/home/xxx/opencv-3.0.0/cmake/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.
-- Configuring incomplete, errors occurred!

解决办法:
在CMakelists.txt 中,find_package(OpenCV REQUIRED)前面添加一句
set(OpenCV_FOUND 1)
既可以通过编译,原因未知,一直觉得是因为opencv没有正确安装造成的


你可能感兴趣的:(openCV,Ubuntu)