标签:struct gcc 头文件 fatal .cpp ctc .com http 环境
$ 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 libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
$ sudo apt-get install libxvidcore-dev libx264-dev # 处理视频所需的包
$ sudo apt-get install libatlas-base-dev gfortran # 优化opencv功能
$ sudo apt-get install ffmpeg
$ cd /the_path_you_would_install
$ wget https://github.com/opencv/opencv/archive/3.2.0.zip
$ wget https://github.com/opencv/opencv_contrib/archive/3.2.0.zip
直接右键解压,然后进行安装。
$ cd opencv-3.2.0
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules/ ..
$ make -j8 #如果线程足够多可以使用 make -j12
$ sudo make install
第四行最后的 .. 一定不能忘记,因为我们是在/build文件夹中编译上层文件夹的程序。
$ sudo ldconfig -v
$ pkg-config --modversion opencv #确认OpenCV的版本,如果显示3.2.0说明安装完成
In file included from /home/yao/opencv-3.2.0/modules/core/src/hal_internal.cpp:49:0:
/home/yao/opencv-3.2.0/build/opencv_lapack.h:2:45: fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h: No such file or directory
compilation terminated.
modules/core/CMakeFiles/opencv_core.dir/build.make:114: recipe for target ‘modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o‘ failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 27%] Built target pch_Generate_opencv_test_optflow
[ 27%] Built target pch_Generate_opencv_perf_optflow
[ 27%] Built target pch_Generate_opencv_test_phase_unwrapping
[ 27%] Built target pch_Generate_opencv_phase_unwrapping
[ 27%] Built target pch_Generate_opencv_test_stitching
[ 27%] Built target pch_Generate_opencv_test_structured_light
[ 27%] Built target pch_Generate_opencv_stitching
[ 27%] Built target pch_Generate_opencv_perf_stitching
[ 27%] Built target pch_Generate_opencv_structured_light
CMakeFiles/Makefile2:1901: recipe for target ‘modules/core/CMakeFiles/opencv_core.dir/all‘ failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:160: recipe for target ‘all‘ failed
make: *** [all] Error 2
$ sudo apt-get install liblapacke-dev checkinstall
在cmake时会产生关于CUDA版本的问题,这种情况在已装CUDA的条件下会出现,未安装时不会有。
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
linked by target "opencv_cudev" in directory
这是由于CUDA 9.0不支持2.0架构,尝试过网上其他方法,包括在cmake时给命令行加入配置属性如CUDA的路径以及配置,皆无效,而以下方案有效。
1) 在/opencv-3.2.0/cmake文件夹下找到FindCUDA.cmake文件
find_cuda_helper_libs(nppi)
改为
find_cuda_helper_libs(nppial)
find_cuda_helper_libs(nppicc)
find_cuda_helper_libs(nppicom)
find_cuda_helper_libs(nppidei)
find_cuda_helper_libs(nppif)
find_cuda_helper_libs(nppig)
find_cuda_helper_libs(nppim)
find_cuda_helper_libs(nppist)
find_cuda_helper_libs(nppisu)
find_cuda_helper_libs(nppitc)
set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")
改为
set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}")
unset(CUDA_nppi_LIBRARY CACHE)
改为
unset(CUDA_nppial_LIBRARY CACHE)
unset(CUDA_nppicc_LIBRARY CACHE)
unset(CUDA_nppicom_LIBRARY CACHE)
unset(CUDA_nppidei_LIBRARY CACHE)
unset(CUDA_nppif_LIBRARY CACHE)
unset(CUDA_nppig_LIBRARY CACHE)
unset(CUDA_nppim_LIBRARY CACHE)
unset(CUDA_nppist_LIBRARY CACHE)
unset(CUDA_nppisu_LIBRARY CACHE)
unset(CUDA_nppitc_LIBRARY CACHE)
2) 找到文件OpenCVDetectCUDA.cmake
删除以下几句
if(CUDA_GENERATION STREQUAL "Fermi")
set(__cuda_arch_bin "2.0")
然后将下一行的elsif改为if
3) 找到文件opencv\modules\cudev\include\opencv2\cudev\common.hpp
添加头文件
#include <cuda_fp16.h>
nvcc fatal : Unsupported gpu architecture ‘compute_20‘
在cmake的时候命令行的参数中加入如下一句
-D CUDA_GENERATION=Kepler
[100%] Built target opencv_perf_stitching
[100%] Built target opencv_python2
这个时候,会一直卡着
set(OpenCV_DIR "/your_opencv_path/opencv-3.2.0/build")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
其中your_opencv_path指你的opencv的安装路径,注意区分大小写。
[环境配置]Ubuntu 16.04 源码编译安装OpenCV-3.2.0+OpenCV_contrib-3.2.0及产生的问题
标签:struct gcc 头文件 fatal .cpp ctc .com http 环境
原文地址:https://www.cnblogs.com/RichardYao/p/9900268.html