红联Linux门户
Linux帮助

Ubuntu opencv多版本管理,已装opencv3.2.0,现安装opencv2.4.8

发布时间:2017-06-21 15:10:13来源:blog.csdn.net/u013832707作者:持久决心
前言
系统Ubuntu14.04
已源码安装opencv3.2.0
现在需要安装opencv2.4.8
 
下载源码
进入opencv2.4.8的安装目录
执行如下命令:
git clone https://github.com/opencv/opencv
cd opencv
git checkout 2.4.8
 
编译安装
cd .. #回到安装目录
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv/2.4.8 -D CUDA_GENERATION=Kepler ../opencv/
make -j8 #多核编译
sudo make install
 
环境配置
首先使用命令
pkg-config --modversion opencv
当前输出为3.2.0
打开~/.bashrc文件,添加以下内容:
export PKG_CONFIG_PATH=/usr/local/opencv/2.4.8/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/local/opencv/2.4.8/lib/
重新打开一个终端,再次查看OpenCV版本,可以看到改为了2.4.8
 
错误记录
错误一
nvcc fatal   : Unsupported gpu architecture 'compute_11'  
CMake Error at cuda_compile_generated_matrix_operations.cu.o.cmake:206 (message):  
Error generating
/home/smie/Documents/opencv2.4.11/build/modules/core/CMakeFiles/cuda_compile. dir/__/dynamicuda/src/cuda/./cuda_compile_gene  
rated_matrix_operations.cu.o  
make[2]: ***  
[modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/ ./cuda_compile_generated_matrix_operations.cu.o] Error 1  
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....  
解决办法,指明GPU的架构,一般的都为开普勒架构。也就是在cmake 命令添加:CUDA_GENERATION=Kepler
 
错误二
/home/ros05/opencv2.4.8/opencv/modules/gpu/src/nvidia/core/NCVPixelOperations.hpp(133): error: a storage class is not allowed in an explicit specialization
31 errors detected in the compilation of "/tmp/tmpxft_00005a7c_00000000-9_NCVPyramid.compute_35.cpp1.ii".
CMake Error at cuda_compile_generated_NCVPyramid.cu.o.cmake:266 (message):
Error generating file
/home/ros05/opencv2.4.8/release/modules/gpu/CMakeFiles/cuda_compile.dir/ src/nvidia/core/./cuda_compile_generated_NCVPyramid.cu.o
make[2]: *** [modules/gpu/CMakeFiles/cuda_compile.dir/src/nvidia/core/ ./cuda_compile_generated_NCVPyramid.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 71%] Built target opencv_perf_ocl
[ 74%] Built target opencv_test_ocl
make[1]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/all] Error 2
make: *** [all] Error 2
替换opencv/modules/gpu/src/nvidia/core中的NCVPixelOperations.hpp 为http://download.csdn.net/detail/u013832707/9875570中文件
 
错误3
‘NppiGraphcutState’ does not name a type
operator NppiGraphcutState*()
^
在graphcuts.cpp中将
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) 
改为
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
 
本文永久更新地址:http://www.linuxdiyf.com/linux/31647.html