当前位置:   article > 正文

ubuntu18.04 with anaconda3 编译 opencv3.4.7_ccache_found-notfound: not found

ccache_found-notfound: not found

 

按照官网先配置环境

编译器(compiler)

sudo apt-get install build-essential

必需(required)

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

可选(optional)

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

除了官网可选之外,还有一些可选

gtk-3.0

sudo apt-get install libgtk-3-dev

gstreamer-1.0

  1. sudo apt-get -y install libgstreamer-plugins-base1.0-dev
  2. sudo apt-get -y install libgstreamer1.0-dev

 other:

  1. sudo apt-get -y install libavresample-dev
  2. sudo apt-get -y install libgphoto2-dev

openblas

apt安装的openblas似乎不行,只能自己下载源码编译,很简单,只需要注意提前安装fortran编译器

sudo apt-get install gfortran

然后去https://github.com/xianyi/OpenBLAS下载下来源码编译好就行

pthread

  1. sudo apt-get install glibc-doc
  2. sudo apt-get install manpages-posix manpages-posix-dev

gflags glog

  1. sudo apt-get install libgflags-dev
  2. sudo apt-get install libgoogle-glog-dev

ceres

sudo apt-get install libceres-dev

运行cmake,这里写成脚本文件比较方便

    1.其中PYTHON用的ANACONDA下的base的python解释器和include路径

    2.需要注意的是opencv-contrib的路径需要精确到model文件夹

    3.由于我是CUDA10.1,nvcuvid.h会出问题,因此添加-DWITH_NVCUVID=ON -DBUILD_opencv_cudacodec=OFF

    4.安装contrib之后发现SIFT无法使用,根据提示重新编译,增加了-D OPENCV_ENABLE_NONFREE=ON

  1. cmake \
  2. -D CMAKE_BUILD_TYPE=Release \
  3. -D CMAKE_INSTALL_PREFIX=/home/kunb/Installed/opencv/opencv/3.4.7 \
  4. -D OPENCV_EXTRA_MODULES_PATH=/home/kunb/Installed/opencv/unziped/opencv_contrib-3.4.7/modules \
  5. -D PYTHON3_EXECUTABLE=/home/kunb/Installed/anaconda3/bin/python3.7 \
  6. -D PYTHON_INCLUDE_DIR=/home/kunb/Installed/anaconda3/include/python3.7m \
  7. -D PYTHON_LIBRARY=/home/kunb/Installed/anaconda3/lib/libpython3.7m.so \
  8. -D PYTHON3_NUMPY_INCLUDE_DIRS=/home/kunb/Installed/anaconda3/lib/python3.7/site-packages/numpy/core/include \
  9. -D OPENCV_GENERATE_PKGCONFIG=ON \
  10. -D WITH_CUDA=ON \
  11. -D WITH_NVCUVID=ON \
  12. -D BUILD_opencv_cudacodec=OFF \
  13. -D OPENCV_ENABLE_NONFREE=ON ..

cmake完成的部分输出 

  1. -- Detected processor: x86_64
  2. -- Looking for ccache - not found
  3. -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3")
  4. -- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)
  5. -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
  6. -- Looking for linux/videodev.h
  7. -- Looking for linux/videodev.h - not found
  8. -- Looking for linux/videodev2.h
  9. -- Looking for linux/videodev2.h - found
  10. -- Looking for sys/videoio.h
  11. -- Looking for sys/videoio.h - not found
  12. -- found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
  13. -- at: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/build/3rdparty/ippicv/ippicv_lnx/icv
  14. -- found Intel IPP Integration Wrappers sources: 2019.0.0
  15. -- at: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/build/3rdparty/ippicv/ippicv_lnx/iw
  16. -- CUDA detected: 10.1
  17. -- CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-D_FORCE_INLINES
  18. -- Found OpenBLAS libraries: /usr/local/lib/libopenblas.a
  19. -- Found OpenBLAS include: /usr/local/include/openblas
  20. -- LAPACK(OpenBLAS): LAPACK_LIBRARIES: /usr/local/lib/libopenblas.a
  21. -- LAPACK(OpenBLAS): Can't build LAPACK check code. This LAPACK version is not supported.
  22. -- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY)
  23. -- A library with BLAS API found.
  24. -- A library with LAPACK API found.
  25. -- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
  26. -- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
  27. -- OpenCV Python: during development append to PYTHONPATH: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/build/python_loader
  28. -- Caffe: NO
  29. -- Protobuf: NO
  30. -- Glog: YES
  31. -- freetype2: YES (ver 21.0.15)
  32. -- harfbuzz: YES (ver 1.7.2)
  33. -- HDF5: Using hdf5 compiler wrapper to determine C configuration
  34. -- Module opencv_ovis disabled because OGRE3D was not found
  35. -- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
  36. -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
  37. -- Detected gflags version: 2.2.1
  38. -- Found installed version of Eigen: /usr/lib/cmake/eigen3
  39. -- Found required Ceres dependency: Eigen version 3.3.4 in /usr/include/eigen3
  40. -- Found required Ceres dependency: glog
  41. -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
  42. -- Detected gflags version: 2.2.1
  43. -- Found required Ceres dependency: gflags
  44. -- Found Ceres version: 1.13.0 installed in: /usr with components: [LAPACK, SuiteSparse, SparseLinearAlgebraLibrary, CXSparse, SchurSpecializations, OpenMP]
  45. -- Checking SFM deps... TRUE
  46. -- HDF5: Using hdf5 compiler wrapper to determine C configuration
  47. -- Checking for module 'tesseract'
  48. -- No package 'tesseract' found
  49. -- Tesseract: NO
  50. -- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
  51. -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
  52. -- Detected gflags version: 2.2.1
  53. -- Found installed version of Eigen: /usr/lib/cmake/eigen3
  54. -- Found required Ceres dependency: Eigen version 3.3.4 in /usr/include/eigen3
  55. -- Found required Ceres dependency: glog
  56. -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
  57. -- Detected gflags version: 2.2.1
  58. -- Found required Ceres dependency: gflags
  59. -- Found Ceres version: 1.13.0 installed in: /usr with components: [LAPACK, SuiteSparse, SparseLinearAlgebraLibrary, CXSparse, SchurSpecializations, OpenMP]
  60. -- Checking SFM deps... TRUE
  61. --
  62. -- General configuration for OpenCV 3.4.7 =====================================
  63. -- Version control: unknown
  64. --
  65. -- Extra modules:
  66. -- Location (extra): /home/kunb/Installed/opencv/unziped/opencv_contrib-3.4.7/modules
  67. -- Version control (extra): unknown
  68. --
  69. -- Platform:
  70. -- Timestamp: 2019-09-01T07:30:05Z
  71. -- Host: Linux 4.15.0-58-generic x86_64
  72. -- CMake: 3.10.2
  73. -- CMake generator: Unix Makefiles
  74. -- CMake build tool: /usr/bin/make
  75. -- Configuration: Release
  76. --
  77. -- CPU/HW features:
  78. -- Baseline: SSE SSE2 SSE3
  79. -- requested: SSE3
  80. -- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
  81. -- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
  82. -- SSE4_1 (14 files): + SSSE3 SSE4_1
  83. -- SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
  84. -- FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
  85. -- AVX (6 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
  86. -- AVX2 (28 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
  87. -- AVX512_SKX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
  88. --
  89. -- C/C++:
  90. -- Built as dynamic libs?: YES
  91. -- C++11: YES
  92. -- C++ Compiler: /usr/bin/c++ (ver 7.4.0)
  93. -- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
  94. -- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
  95. -- C Compiler: /usr/bin/cc
  96. -- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
  97. -- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
  98. -- Linker flags (Release): -Wl,--gc-sections
  99. -- Linker flags (Debug): -Wl,--gc-sections
  100. -- ccache: NO
  101. -- Precompiled headers: YES
  102. -- Extra dependencies: m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64 -L/usr/lib/x86_64-linux-gnu
  103. -- 3rdparty dependencies:
  104. --
  105. -- OpenCV modules:
  106. -- To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
  107. -- Disabled: cudacodec world
  108. -- Disabled by dependency: -
  109. -- Unavailable: cnn_3dobj cvv java js matlab ovis python2 viz
  110. -- Applications: tests perf_tests apps
  111. -- Documentation: NO
  112. -- Non-free algorithms: NO
  113. --
  114. -- GUI:
  115. -- GTK+: YES (ver 3.22.30)
  116. -- GThread : YES (ver 2.56.4)
  117. -- GtkGlExt: NO
  118. -- VTK support: NO
  119. --
  120. -- Media I/O:
  121. -- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
  122. -- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
  123. -- WEBP: build (ver encoder: 0x020e)
  124. -- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
  125. -- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
  126. -- JPEG 2000: build (ver 1.900.1)
  127. -- OpenEXR: build (ver 2.3.0)
  128. -- HDR: YES
  129. -- SUNRASTER: YES
  130. -- PXM: YES
  131. --
  132. -- Video I/O:
  133. -- DC1394: YES (ver 2.2.5)
  134. -- FFMPEG: YES
  135. -- avcodec: YES (ver 57.107.100)
  136. -- avformat: YES (ver 57.83.100)
  137. -- avutil: YES (ver 55.78.100)
  138. -- swscale: YES (ver 4.8.100)
  139. -- avresample: YES (ver 3.7.0)
  140. -- GStreamer: YES
  141. -- base: YES (ver 1.14.5)
  142. -- video: YES (ver 1.14.5)
  143. -- app: YES (ver 1.14.5)
  144. -- riff: YES (ver 1.14.5)
  145. -- pbutils: YES (ver 1.14.5)
  146. -- libv4l/libv4l2: NO
  147. -- v4l/v4l2: linux/videodev2.h
  148. --
  149. -- Parallel framework: pthreads
  150. --
  151. -- Trace: YES (with Intel ITT)
  152. --
  153. -- Other third-party libraries:
  154. -- Intel IPP: 2019.0.0 Gold [2019.0.0]
  155. -- at: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/build/3rdparty/ippicv/ippicv_lnx/icv
  156. -- Intel IPP IW: sources (2019.0.0)
  157. -- at: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/build/3rdparty/ippicv/ippicv_lnx/iw
  158. -- Lapack: NO
  159. -- Eigen: YES (ver 3.3.4)
  160. -- Custom HAL: NO
  161. -- Protobuf: build (3.5.1)
  162. --
  163. -- NVIDIA CUDA: YES (ver 10.1, CUFFT CUBLAS NVCUVID)
  164. -- NVIDIA GPU arch: 30 35 37 50 52 60 61 70 75
  165. -- NVIDIA PTX archs:
  166. --
  167. -- OpenCL: YES (no extra features)
  168. -- Include path: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/3rdparty/include/opencl/1.2
  169. -- Link libraries: Dynamic load
  170. --
  171. -- Python 3:
  172. -- Interpreter: /home/kunb/Installed/anaconda3/bin/python3.7 (ver 3.7.3)
  173. -- Libraries: /home/kunb/Installed/anaconda3/lib/libpython3.7m.so (ver 3.7.3)
  174. -- numpy: /home/kunb/Installed/anaconda3/lib/python3.7/site-packages/numpy/core/include (ver 1.16.4)
  175. -- install path: lib/python3.7/site-packages/cv2/python-3.7
  176. --
  177. -- Python (for build): /usr/bin/python2.7
  178. --
  179. -- Java:
  180. -- ant: NO
  181. -- JNI: NO
  182. -- Java wrappers: NO
  183. -- Java tests: NO
  184. --
  185. -- Install to: /home/kunb/Installed/opencv/opencv/3.4.7
  186. -- -----------------------------------------------------------------
  187. --
  188. -- Configuring done
  189. -- Generating done
  190. -- Build files have been written to: /home/kunb/Installed/opencv/unziped/opencv-3.4.7/build

随后

  1. make -j8
  2. make install

附注:

1.cmake过程中遇到eigen路径问题,具体文件忘记了,直接找到出错的源文件,修改为#include<eigen3/Eigen/xxx>

2.python 使用时import cv2出现如下两个报错

  1. ImportError: /home/kunb/Installed/anaconda3/bin/../lib/libfontconfig.so.1: undefined symbol: FT_Done_MM_Var
  2. ImportError: /home/kunb/Installed/anaconda3/bin/../lib/libpangoft2-1.0.so.1: undefined symbol: FcWeightToOpenTypeDouble

网上给的原因是版本问题造成的,所以将

/usr/lib/x86_64-linux-gnu

之中较低版本的cp过来建立软连接就解决了

  1. sudo cp ./libfontconfig.so.1.10.1 /home/kunb/Installed/anaconda3/lib
  2. ln -s libfontconfig.so.1.10.1 libfontconfig.so.1
  3. ln -s libfontconfig.so.1.10.1 libfontconfig.so
  4. sudo cp ./libpangoft2-1.0.so.0.4000.14 /home/kunb/Installed/anaconda3/lib
  5. ln -s libpangoft2-1.0.so.0.4000.14 libpangoft2-1.0.so
  6. ln -s libpangoft2-1.0.so.0.4000.14 libpangoft2-1.0.so.0

3.由于我没有将prefix设置为/usr/local,另外也为了使用不同版本的opencv,所以在使用时需要设置PYTHONPATH

  1. sudo gedit ~/.bashrc
  2. ###编辑完成后激活
  3. source ~/.bashrc

编辑内容,在末尾添加,路径按需更改,:是用来分隔的

  1. export CPLUS_INCLUDE_PATH="/home/kunb/Installed/opencv/opencv/3.4.7/include:$CPLUS_INCLUDE_PATH"
  2. export C_INCLUDE_PATH="/home/kunb/Installed/opencv/opencv/3.4.7/include:$C_INCLUDE_PATH"
  3. export LIBRARY_PATH="/home/kunb/Installed/opencv/opencv/3.4.7/lib:$LIBRARY_PATH"
  4. export LD_LIBRARY_PATH="/home/kunb/Installed/opencv/opencv/3.4.7/lib:$LD_LIBRARY_PATH"
  5. export PYTHONPATH="/home/kunb/Installed/opencv/opencv/3.4.7/lib/python3.7/site-packages:$PYTHONPATH"

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/119771
推荐阅读
相关标签
  

闽ICP备14008679号