<p dir="auto">I am having this problem when installing OpenCV3 in a virtual environment--</p>
<p dir="auto">[ 23%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o<br>
/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’:<br>
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope<br>
return (char *) memcpy (__dest, __src, __n) + __n;<br>
^<br>
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:266 (message):<br>
Error generating file<br>
/home/gamer/opencv/build/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o</p>
<p dir="auto">modules/core/CMakeFiles/opencv_core.dir/build.make:398: recipe for target 'modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o' failed<br>
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1<br>
CMakeFiles/Makefile2:2248: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed<br>
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2<br>
Makefile:149: recipe for target 'all' failed<br>
make: *** [all] Error 2</p>
<p dir="auto"><strong>My Cmake:</strong><br>
(.venv2) gamer@gamer:<del>/opencv/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=</del>/opencv_contrib/modules -D BUILD_EXAMPLES=ON ..</p>
<p dir="auto"><strong>General config:</strong></p>
<h2 dir="auto">-- General configuration for OpenCV 3.0.0 =====================================<br>
--   Version control:               3.0.0</h2>
<h2 dir="auto">--   Platform:<br>
--     Host:                        Linux 4.10.0-35-generic x86_64<br>
--     CMake:                       3.5.1<br>
--     CMake generator:             Unix Makefiles<br>
--     CMake build tool:            /usr/bin/make<br>
--     Configuration:               RELEASE</h2>
<h2 dir="auto">--   C/C++:<br>
--     Built as dynamic libs?:      YES<br>
--     C++ Compiler:                /usr/bin/c++  (ver 5.4.0)<br>
--     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<br>
--     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<br>
--     C Compiler:                  /usr/bin/cc<br>
--     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<br>
--     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<br>
--     Linker flags (Release):<br>
--     Linker flags (Debug):<br>
--     Precompiled headers:         YES<br>
--     Extra dependencies:          /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libtiff.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 gobject-2.0 fontconfig freetype gthread-2.0 glib-2.0 dc1394 v4l1 v4l2 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg dl m pthread rt cudart nppc nppi npps cufft<br>
--     3rdparty dependencies:       libwebp ippicv</h2>
<h2 dir="auto">--   OpenCV modules:<br>
--     To be built:                 hal cudev core cudaarithm flann imgproc ml reg surface_matching video cudabgsegm cudafilters cudaimgproc cudawarping face imgcodecs photo shape videoio cudacodec highgui objdetect optflow tracking ts ximgproc xobjdetect xphoto adas bgsegm bioinspired features2d latentsvm line_descriptor saliency text calib3d ccalib cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo datasets rgbd superres videostab xfeatures2d stitching python2 python3<br>
--     Disabled:                    world contrib_world<br>
--     Disabled by dependency:      -<br>
--     Unavailable:                 java viz cvv matlab</h2>
<h2 dir="auto">--   GUI:<br>
--     QT:                          NO<br>
--     GTK+ 2.x:                    YES (ver 2.24.30)<br>
--     GThread :                    YES (ver 2.48.2)<br>
--     GtkGlExt:                    NO<br>
--     OpenGL support:              NO<br>
--     VTK support:                 NO</h2>
<h2 dir="auto">--   Media I/O:<br>
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)<br>
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )<br>
--     WEBP:                        build (ver 0.3.1)<br>
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)<br>
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)<br>
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)<br>
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)<br>
--     GDAL:                        NO</h2>
<h2 dir="auto">--   Video I/O:<br>
--     DC1394 1.x:                  NO<br>
--     DC1394 2.x:                  YES (ver 2.2.4)<br>
--     FFMPEG:                      YES<br>
--       codec:                     YES (ver 56.60.100)<br>
--       format:                    YES (ver 56.40.101)<br>
--       util:                      YES (ver 54.31.100)<br>
--       swscale:                   YES (ver 3.1.101)<br>
--       resample:                  NO<br>
--       gentoo-style:              YES<br>
--     GStreamer:                   NO<br>
--     OpenNI:                      NO<br>
--     OpenNI PrimeSensor Modules:  NO<br>
--     OpenNI2:                     NO<br>
--     PvAPI:                       NO<br>
--     GigEVisionSDK:               NO<br>
--     UniCap:                      NO<br>
--     UniCap ucil:                 NO<br>
--     V4L/V4L2:                    Using libv4l1 (ver 1.10.0) / libv4l2 (ver 1.10.0)<br>
--     XIMEA:                       NO<br>
--     Xine:                        NO<br>
--     gPhoto2:                     NO</h2>
<h2 dir="auto">--   Other third-party libraries:<br>
--     Use IPP:                     8.2.1 [8.2.1]<br>
--          at:                     /home/gamer/opencv/3rdparty/ippicv/unpack/ippicv_lnx<br>
--     Use IPP Async:               NO<br>
--     Use Eigen:                   NO<br>
--     Use TBB:                     NO<br>
--     Use OpenMP:                  NO<br>
--     Use GCD                      NO<br>
--     Use Concurrency              NO<br>
--     Use C=:                      NO<br>
--     Use pthreads for parallel for:<br>
--                                  YES<br>
--     Use Cuda:                    YES (ver 7.5)<br>
--     Use OpenCL:                  YES</h2>
<h2 dir="auto">--   NVIDIA CUDA<br>
--     Use CUFFT:                   YES<br>
--     Use CUBLAS:                  NO<br>
--     USE NVCUVID:                 NO<br>
--     NVIDIA GPU arch:             20 21 30 35<br>
--     NVIDIA PTX archs:            30<br>
--     Use fast math:               NO</h2>
<h2 dir="auto">--   OpenCL:<br>
--     Version:                     dynamic<br>
--     Include path:                /home/gamer/opencv/3rdparty/include/opencl/1.2<br>
--     Use AMDFFT:                  NO<br>
--     Use AMDBLAS:                 NO</h2>
<h2 dir="auto">--   Python 2:<br>
--     Interpreter:                 /home/gamer/neon/.venv2/bin/python2.7 (ver 2.7.12)<br>
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)<br>
--     numpy:                       /home/gamer/neon/.venv2/local/lib/python2.7/site-packages/numpy/core/include (ver 1.13.1)<br>
--     packages path:               lib/python2.7/site-packages</h2>
<h2 dir="auto">--   Python 3:<br>
--     Interpreter:                 /usr/bin/python3 (ver 3.5.2)<br>
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2)<br>
--     numpy:                       /home/gamer/.local/lib/python3.5/site-packages/numpy/core/include (ver 1.13.0)<br>
--     packages path:               lib/python3.5/site-packages</h2>
<h2 dir="auto">--   Python (for build):            /home/gamer/neon/.venv2/bin/python2.7</h2>
<h2 dir="auto">--   Java:<br>
--     ant:                         NO<br>
--     JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include<br>
--     Java wrappers:               NO<br>
--     Java tests:                  NO</h2>
<h2 dir="auto">--   Matlab:<br>
--     mex:                         NO</h2>
<h2 dir="auto">--   Documentation:<br>
--     Doxygen:                     NO<br>
--     PlantUML:                    NO</h2>
<h2 dir="auto">--   Tests and samples:<br>
--     Tests:                       YES<br>
--     Performance tests:           YES<br>
--     C/C++ Examples:              YES</h2>
<h2 dir="auto">--   Install path:                  /usr/local</h2>
<p dir="auto">--   cvconfig.h is in:              /home/gamer/opencv/build</p>
<h3 dir="auto">Please state the information for your system</h3>
<ul dir="auto">
<li>OpenCV version:  3.0/3.1/master</li>
<li>Host OS: Linux (Ubuntu 16.04)</li>
<li>Compiler: GCC 4.7/4.8/4.9/5.0</li>
<li>CUDA 7.5 (from synaptic package manager ("nvidia-cuda-toolkit"))</li>
</ul>
<h3 dir="auto">In which part of the OpenCV library you got the issue?</h3>
<ul dir="auto">
<li>cuda</li>
</ul>
<p dir="auto">When trying to compile opencv (ubuntu 16.04) i get the following error:</p>
<p dir="auto">[  9%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o<br>
/usr/include/string.h: In function ‘void* <em><em>mempcpy_inline(void</em>, const void</em>, size_t)’:<br>
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope<br>
return (char *) memcpy (__dest, __src, __n) + __n;<br>
^<br>
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:264 (message):<br>
Error generating file<br>
/home/mag/opencv/build_opencv_master/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o</p>
<p dir="auto">The problem is known, but you need to make a workaround to support cuda. Here is a link to the same Proplem in the caffe git, but unfortunetly the solution doesnt work for me:<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="151135972" data-permission-text="Title is private" data-url="https://github.com/BVLC/caffe/issues/4046" data-hovercard-type="issue" data-hovercard-url="/BVLC/caffe/issues/4046/hovercard" href="https://github.com/BVLC/caffe/issues/4046">BVLC/caffe#4046</a></p>