Trying to build OpenCV on Ubuntu 16.04, make fails with an error compiling cuda file:
[ 16%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o /usr/include/string.h: In function ‘void* __mempcpy_inline(void, const void, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char ) memcpy (__dest, __src, __n) + __n; ^ CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:266 (message): Error generating file /home/johann/Downloads/opencv-3.1.0/release/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o modules/core/CMakeFiles/opencv_core.dir/build.make:63: recipe for target 'modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o' failed make[2]: [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1 CMakeFiles/Makefile2:1722: 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
Below is the output from the CMAKE configuration step:
johann@mars:~/Downloads/opencv-3.1.0/release$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON .. -- Detected version of GNU GCC: 54 (504) -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") -- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) -- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) -- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") -- Checking for module 'gstreamer-base-1.0' -- No package 'gstreamer-base-1.0' found -- Checking for module 'gstreamer-video-1.0' -- No package 'gstreamer-video-1.0' found -- Checking for module 'gstreamer-app-1.0' -- No package 'gstreamer-app-1.0' found -- Checking for module 'gstreamer-riff-1.0' -- No package 'gstreamer-riff-1.0' found -- Checking for module 'gstreamer-pbutils-1.0' -- No package 'gstreamer-pbutils-1.0' found -- Checking for module 'gstreamer-base-0.10' -- No package 'gstreamer-base-0.10' found -- Checking for module 'gstreamer-video-0.10' -- No package 'gstreamer-video-0.10' found -- Checking for module 'gstreamer-app-0.10' -- No package 'gstreamer-app-0.10' found -- Checking for module 'gstreamer-riff-0.10' -- No package 'gstreamer-riff-0.10' found -- Checking for module 'gstreamer-pbutils-0.10' -- No package 'gstreamer-pbutils-0.10' found -- Checking for module 'libdc1394-2' -- No package 'libdc1394-2' found -- Checking for module 'libdc1394' -- No package 'libdc1394' found -- Checking for module 'libv4l1' -- No package 'libv4l1' found -- Checking for module 'libv4l2' -- No package 'libv4l2' found -- 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 -- Checking for module 'libavresample' -- No package 'libavresample' found -- Looking for libavformat/avformat.h -- Looking for libavformat/avformat.h - found -- Looking for ffmpeg/avformat.h -- Looking for ffmpeg/avformat.h - not found -- Checking for module 'libgphoto2' -- No package 'libgphoto2' found -- found IPP (ICV version): 9.0.1 [9.0.1] -- at: /home/johann/Downloads/opencv-3.1.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 -- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.7") -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.5.2", minimum required is "3.4") -- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is exact version "3.5.2") Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named 'numpy' -- 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)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- General configuration for OpenCV 3.1.0 =====================================
-- Version control: unknown
-- Platform: -- Host: Linux 4.4.0-47-generic x86_64 -- CMake: 3.5.1 -- 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.4.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: /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so gtk-3 gdk-3 pangocairo-1.0 pango-1.0 atk-1.0 cairo-gobject cairo gdk_pixbuf-2.0 gio-2.0 gobject-2.0 gthread-2.0 glib-2.0 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg dl m pthread rt cudart nppc nppi npps cufft -L/usr/lib/x86_64-linux-gnu
-- 3rdparty dependencies: libjpeg libwebp libtiff libjasper IlmImf
-- OpenCV modules: -- To be built: cudev core cudaarithm flann imgproc ml video cudabgsegm cudafilters cudaimgproc cudawarping imgcodecs photo shape videoio cudacodec highgui objdetect ts features2d calib3d cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo stitching superres videostab python2 -- Disabled: world -- Disabled by dependency: -
-- Unavailable: java python3 viz
-- GUI: -- QT: NO -- GTK+ 3.x: YES (ver 3.18.9) -- GThread : YES (ver 2.48.1) -- GtkGlExt: NO -- OpenGL support: NO
-- VTK support: NO
-- Media I/O: -- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8) -- JPEG: libjpeg (ver 90) -- WEBP: build (ver 0.3.1) -- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54) -- TIFF: build (ver 42 - 4.0.2) -- JPEG 2000: build (ver 1.900.1) -- OpenEXR: build (ver 1.7.1)
-- GDAL: NO
-- Video I/O: -- DC1394 1.x: NO -- DC1394 2.x: NO -- FFMPEG: YES -- codec: YES (ver 56.60.100) -- format: YES (ver 56.40.101) -- util: YES (ver 54.31.100) -- swscale: YES (ver 3.1.101) -- resample: NO -- gentoo-style: YES -- GStreamer: NO -- OpenNI: NO -- OpenNI PrimeSensor Modules: NO -- OpenNI2: NO -- PvAPI: NO -- GigEVisionSDK: NO -- UniCap: NO -- UniCap ucil: NO -- V4L/V4L2: NO/YES -- XIMEA: NO -- Xine: NO
-- gPhoto2: NO
-- Parallel framework: pthreads
-- Other third-party libraries: -- Use IPP: 9.0.1 [9.0.1] -- at: /home/johann/Downloads/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx -- Use IPP Async: NO -- Use VA: NO -- Use Intel VA-API/OpenCL: NO -- Use Eigen: NO -- Use Cuda: YES (ver 7.5) -- Use OpenCL: YES
-- Use custom HAL: NO
-- 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/johann/Downloads/opencv-3.1.0/3rdparty/include/opencl/1.2 -- Use AMDFFT: NO
-- Use AMDBLAS: NO
-- Python 2: -- Interpreter: /usr/bin/python2.7 (ver 2.7.12) -- Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12) -- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
-- packages path: lib/python2.7/dist-packages
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.5.2)
-- Python (for build): /usr/bin/python2.7
-- Java: -- ant: NO -- JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include -- Java wrappers: NO
-- Java tests: NO
-- Matlab: Matlab not found or implicitly disabled
-- Documentation: -- Doxygen: /usr/bin/doxygen (ver 1.8.11)
-- PlantUML: NO
-- Tests and samples: -- Tests: YES -- Performance tests: YES
-- C/C++ Examples: NO
-- Install path: /usr/local
-- cvconfig.h is in: /home/johann/Downloads/opencv-3.1.0/release
-- -----------------------------------------------------------------
-- Configuring done -- Generating done -- Build files have been written to: /home/johann/Downloads/opencv-3.1.0/release