我已经使用成功构建了 OpenCV这个linux安装教程过去在 Ubuntu 发行版上构建它,但最近,我需要在 Arch Linux 发行版上构建它。
该命令
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. -Wno-dev
生成一个明显无错误的日志,包括以下几行
Detected version of GNU GCC: 52 (502)
... <skipped lines> ...
C Compiler: /usr/bin/cc
但是当我运行make
命令时,出现以下错误
/usr/bin/gcc-5: No such file or directory
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:208 (message): Error generating /home/cecilia/opencv-3.0.0/build/modules/core/CMakeFiles/cuda_compile.dir
/src/cuda/./cuda_compile_generated_gpu_mat.cu.o
这显然是错误的道路。gcc
是在usr/bin/gcc
。为了仔细检查它gcc
在系统路径上,我运行了gcc -v
生产
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-5.2.0/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.2.0 (GCC)
它与日志中的版本号相匹配cmake
。
为什么cmake
检测到正确的gcc版本却make
使用了错误的路径?我该如何解决这个错误?
ps 完整的 cmake 日志如下,以防我错过了您可以发现的内容。
-- Detected version of GNU GCC: 52 (502)
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Found OpenEXR: /lib64/libIlmImf.so
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- found IPP (ICV version): 8.2.1 [8.2.1]
-- at: /home/cecilia/opencv-3.0.0/3rdparty/ippicv/unpack/ippicv_lnx
-- CUDA detected: 7.5
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
-- Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "3.4" (found /usr/bin/python3.4)
-- Could NOT find PythonInterp: Found unsuitable version "1.4", but required is at least "3.2" (found )
-- Found apache ant 1.9.6: /bin/ant
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- Found VTK ver. 6.3.0 (usefile: /usr/lib/cmake/vtk-6.3/UseVTK.cmake)
-- Assume that non-module dependency is available: /usr/lib/x86_64-linux-gnu/libz.so (for module opencv_core)
-- Assume that non-module dependency is available: /usr/lib64/libgl2ps.so (for module opencv_viz)
-- videoio: Removing WinRT API headers by default
--
-- General configuration for OpenCV 3.0.0 =====================================
-- Version control: unknown
--
-- Platform:
-- Host: Linux 4.2.5-1-ARCH x86_64
-- CMake: 3.3.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/bin/c++ (ver 5.2.0)
-- 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 -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- 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 -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- 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 -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- 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 -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- Precompiled headers: YES
-- Extra dependencies: /lib64/libwebp.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so /lib64/libtiff.so /lib64/libjasper.so /lib64/libjpeg.so /lib64/libImath.so /lib64/libIlmImf.so /lib64/libIex.so /lib64/libHalf.so /lib64/libIlmThread.so gtk-3 gdk-3 pangocairo-1.0 pango-1.0 atk-1.0 cairo-gobject cairo gdk_pixbuf-2.0 gio-2.0 gthread-2.0 gstvideo-1.0 gstapp-1.0 gstbase-1.0 gstriff-1.0 gstpbutils-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 dc1394 v4l1 v4l2 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg avresample gphoto2 gphoto2_port exif /lib64/libbz2.so /usr/lib64/libfreetype.so /usr/lib64/libgl2ps.so /usr/lib64/libjpeg.so /usr/lib64/libpng.so /usr/lib64/libtiff.so /usr/lib64/libz.so vtkCommonColor vtkCommonComputationalGeometry vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkDICOMParser vtkFiltersCore vtkFiltersExtraction vtkFiltersGeneral vtkFiltersGeometry vtkFiltersModeling vtkFiltersSources vtkFiltersStatistics vtkFiltersTexture vtkIOCore vtkIOExport vtkIOGeometry vtkIOImage vtkIOPLY vtkImagingColor vtkImagingCore vtkImagingFourier vtkImagingHybrid vtkInteractionStyle vtkRenderingAnnotation vtkRenderingContext2D vtkRenderingContextOpenGL vtkRenderingCore vtkRenderingFreeType vtkRenderingGL2PS vtkRenderingLOD vtkRenderingLabel vtkRenderingOpenGL vtkalglib vtkftgl vtkmetaio vtksys dl m pthread rt cudart nppc nppi npps cufft
-- 3rdparty dependencies: ippicv
--
-- OpenCV modules:
-- To be built: hal cudev core cudaarithm flann imgproc ml video viz cudabgsegm cudafilters cudaimgproc cudawarping imgcodecs photo shape videoio cudacodec highgui objdetect ts features2d calib3d cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo java stitching superres videostab
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: python2 python3
--
-- GUI:
-- QT: NO
-- GTK+ 3.x: YES (ver 3.18.2)
-- GThread : YES (ver 2.46.1)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: YES (ver 6.3.0)
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
-- JPEG: /lib64/libjpeg.so (ver )
-- WEBP: /lib64/libwebp.so (ver encoder: 0x0202)
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver ..)
-- TIFF: /lib64/libtiff.so (ver 42 - 4.0.6)
-- JPEG 2000: /lib64/libjasper.so (ver 1.900.1)
-- OpenEXR: /lib64/libImath.so /lib64/libIlmImf.so /lib64/libIex.so /lib64/libHalf.so /lib64/libIlmThread.so (ver 2.2.0)
-- GDAL: NO
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES (ver 2.2.3)
-- FFMPEG: YES
-- codec: YES (ver 56.41.100)
-- format: YES (ver 56.36.100)
-- util: YES (ver 54.27.100)
-- swscale: YES (ver 3.1.101)
-- resample: YES (ver 2.1.0)
-- gentoo-style: YES
-- GStreamer:
-- base: YES (ver 1.6.1)
-- video: YES (ver 1.6.1)
-- app: YES (ver 1.6.1)
-- riff: YES (ver 1.6.1)
-- pbutils: YES (ver 1.6.1)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- OpenNI2: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l1 (ver 1.6.3) / libv4l2 (ver 1.6.3)
-- XIMEA: NO
-- Xine: NO
-- gPhoto2: YES
--
-- Other third-party libraries:
-- Use IPP: 8.2.1 [8.2.1]
-- at: /home/cecilia/opencv-3.0.0/3rdparty/ippicv/unpack/ippicv_lnx
-- Use IPP Async: NO
-- Use Eigen: NO
-- Use TBB: NO
-- Use OpenMP: NO
-- Use GCD NO
-- Use Concurrency NO
-- Use C=: NO
-- Use pthreads for parallel for:
-- YES
-- Use Cuda: YES (ver 7.5)
-- Use OpenCL: YES
--
-- NVIDIA CUDA
-- Use CUFFT: YES
-- Use CUBLAS: NO
-- USE NVCUVID: NO
-- NVIDIA GPU arch: 20 21 30 35
-- NVIDIA PTX archs: 30
-- Use fast math: NO
--
-- OpenCL:
-- Version: dynamic
-- Include path: /home/cecilia/opencv-3.0.0/3rdparty/include/opencl/1.2
-- Use AMDFFT: NO
-- Use AMDBLAS: NO
--
-- Python 2:
-- Interpreter: /usr/bin/python2.7 (ver 2.7.10)
--
-- Python 3:
-- Interpreter: NO
--
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: /bin/ant (ver 1.9.6)
-- JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
-- Java wrappers: YES
-- Java tests: YES
--
-- Matlab:
-- mex: NO
--
-- Documentation:
-- Doxygen: /usr/bin/doxygen (ver 1.8.10)
-- PlantUML: NO
--
-- Tests and samples:
-- Tests: YES
-- Performance tests: YES
-- C/C++ Examples: NO
--
-- Install path: /usr/local
--
-- cvconfig.h is in: /home/cecilia/opencv-3.0.0/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cecilia/opencv-3.0.0/build
答案1
我从我的 Ubuntu 机器复制了 opencv 目录,并假设这cmake
会覆盖之前设置的任何变量。但是,我相信 CMakeCache.txt 没有被覆盖,导致路径识别错误。
轻松修复:
- 从以下位置下载干净的 opencv 发行版http://opencv.org/
- 像以前一样按照教程进行操作。
答案2
首先,您的系统不是最新的。更新它与pacman -Syu
.你说你的gcc是5.2.0版本。当前版本是6.3.1。所以不知怎的,CMake想使用/usr/bin/gcc-5
which does notise来代替/usr/bin/gcc
.
其次,有ABS。您可以确保本地 ABS 树是最新的。然后复制/var/abs/extra/opencv
到某个目录并运行makepkg
。
第三,即使您出于某种原因不想使用 ABS,也不应该/usr/local
在 Arch Linux 中使用。看https://wiki.archlinux.org/index.php/Arch_packaging_standards#Directories。你应该改用/usr
。