title: OpenCV installation with cuda9 error: Makefile:160: recipe for target 'all' failed make: *** [all] Error 2
body: <p>I am trying to install OpenCV 3.3 on Ubuntu 16.04 with CUDA 9 and Caffe framework. I am following this guide: <a href="https://github.com/BVLC/caffe/wiki/Op" rel="nofollow noreferrer">https://github.com/BVLC/caffe/wiki/Op</a>... </p>
  
  <p>I already changed the FindCUDA. <code>cmake</code> and OpenCVDetectCUDA. cmake file according to CUDA9 requirement and finished building environment successfully by running: </p>
  
  <pre><code>cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D FORCE_VTK=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES --expt-relaxed-constexpr" -D WITH_GDAL=ON -D WITH_XINE=ON -D BUILD_EXAMPLES=ON .. 
  </code></pre>
  
  <p>However when I try: </p>
  
  <pre><code>make -j $(($(nproc) + 1))
  </code></pre>
  
  <p>It is giving me an error as follows: </p>
  
  <pre><code>[ 43%] Linking CXX executable ../../bin/opencv_annotation
  [ 43%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/feature2d.cpp.o
  //usr/lib/libblas.so.3: undefined reference to `gotoblas'
  collect2: error: ld returned 1 exit status
  apps/annotation/CMakeFiles/opencv_annotation.dir/build.make:105: recipe for target 'bin/opencv_annotation' failed
  make[2]: *** [bin/opencv_annotation] Error 1
  CMakeFiles/Makefile2:11912: recipe for target 'apps/annotation/CMakeFiles/opencv_annotation.dir/all' failed
  make[1]: *** [apps/annotation/CMakeFiles/opencv_annotation.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  [ 43%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/main.cpp.o
  [ 43%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/fast.cpp.o
  [ 43%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/matchers.cpp.o
  [ 43%] Built target opencv_cudaarithm
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/blobdetector.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/agast_score.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/bagofwords.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/keypoint.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/dynamic.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/orb.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/kaze/KAZEFeatures.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/kaze/nldiffusion_functions.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/kaze/fed.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/kaze/AKAZEFeatures.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/mser.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/evaluation.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/draw.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/fast_score.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/kaze.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/gftt.cpp.o
  [ 44%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/opencl_kernels_features2d.cpp.o
  [ 44%] Linking CXX static library ../../lib/libopencv_ts.a
  [ 44%] Built target opencv_ts
  [ 44%] Linking CXX shared library ../../lib/libopencv_features2d.so
  [ 44%] Built target opencv_features2d
  Scanning dependencies of target opencv_cudawarping
  [ 44%] Building CXX object modules/cudawarping/CMakeFiles/opencv_cudawarping.dir/src/pyramids.cpp.o
  [ 44%] Building CXX object modules/cudawarping/CMakeFiles/opencv_cudawarping.dir/src/warp.cpp.o
  [ 44%] Building CXX object modules/cudawarping/CMakeFiles/opencv_cudawarping.dir/src/resize.cpp.o
  [ 44%] Building CXX object modules/cudawarping/CMakeFiles/opencv_cudawarping.dir/src/remap.cpp.o
  [ 44%] Linking CXX shared library ../../lib/libopencv_cudawarping.so
  [ 44%] Built target opencv_cudawarping
  Makefile:160: recipe for target 'all' failed
  make: *** [all] Error 2
  </code></pre>
  
  <p>Please help me with this.</p>
  
  <p>I am showing the configuration of OpenCV after running CMake:</p>
  
  <pre><code>    General configuration for OpenCV 3.3.0 =====================================
  --   Version control:               unknown
  -- 
  --   Platform:
  --     Timestamp:                   2017-12-05T10:25:10Z
  --     Host:                        Linux 4.10.0-40-generic x86_64
  --     CMake:                       3.5.1
  --     CMake generator:             Unix Makefiles
  --     CMake build tool:            /usr/bin/make
  --     Configuration:               RELEASE
  -- 
  --   CPU/HW features:
  --     Baseline:                    SSE SSE2 SSE3
  --       requested:                 SSE3
  --     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
  --       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
  --       SSE4_1 (2 files):          + SSSE3 SSE4_1
  --       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
  --       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
  --       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
  --       AVX2 (7 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
  -- 
  --   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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
  --     Linker flags (Release):
  --     Linker flags (Debug):
  --     ccache:                      NO
  --     Precompiled headers:         YES
  --     Extra dependencies:          /usr/lib/libopenblas.so Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libwebp.so /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 /usr/lib/libgdal.so gstbase-0.10 gstreamer-0.10 gobject-2.0 gmodule-2.0 gthread-2.0 glib-2.0 xml2 gstvideo-0.10 gstapp-0.10 gstriff-0.10 gstpbutils-0.10 dc1394 xine avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libtbb.so cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64
  --     3rdparty dependencies:
  -- 
  --   OpenCV modules:
  --     To be built:                 cudev core cudaarithm flann imgproc ml objdetect video cudabgsegm cudafilters cudaimgproc cudawarping dnn imgcodecs photo shape videoio cudacodec highgui ts features2d calib3d cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo stitching superres videostab python2
  --     Disabled:                    world
  --     Disabled by dependency:      -
  --     Unavailable:                 java python3 viz
  -- 
  --   GUI: 
  --     QT 5.x:                      YES (ver 5.5.1)
  --     QT OpenGL support:           YES (Qt5::OpenGL 5.5.1)
  --     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
  --     VTK support:                 NO
  -- 
  --   Media I/O: 
  --     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
  --     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
  --     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
  --     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
  --     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
  --     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
  --     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)
  --     GDAL:                        /usr/lib/libgdal.so
  --     GDCM:                        NO
  -- 
  --   Video I/O:
  --     DC1394 1.x:                  NO
  --     DC1394 2.x:                  YES (ver 2.2.4)
  --     FFMPEG:                      YES
  --       avcodec:                   YES (ver 56.60.100)
  --       avformat:                  YES (ver 56.40.101)
  --       avutil:                    YES (ver 54.31.100)
  --       swscale:                   YES (ver 3.1.101)
  --       avresample:                NO
  --     GStreamer:                   
  --       base:                      YES (ver 0.10.36)
  --       video:                     YES (ver 0.10.36)
  --       app:                       YES (ver 0.10.36)
  --       riff:                      YES (ver 0.10.36)
  --       pbutils:                   YES (ver 0.10.36)
  --     OpenNI:                      NO
  --     OpenNI PrimeSensor Modules:  NO
  --     OpenNI2:                     NO
  --     PvAPI:                       NO
  --     GigEVisionSDK:               NO
  --     Aravis SDK:                  NO
  --     UniCap:                      NO
  --     UniCap ucil:                 NO
  --     V4L/V4L2:                    NO/YES
  --     XIMEA:                       NO
  --     Xine:                        YES (ver 1.2.6)
  --     Intel Media SDK:             NO
  --     gPhoto2:                     NO
  -- 
  --   Parallel framework:            TBB (ver 4.4 interface 9002)
  -- 
  --   Trace:                         YES (with Intel ITT)
  -- 
  --   Other third-party libraries:
  --     Use Intel IPP:               2017.0.2 [2017.0.2]
  --                at:               /home/rohit/opencv-3.3.0/build/3rdparty/ippicv/ippicv_lnx
  --     Use Intel IPP IW:            prebuilt binaries (2017.0.2)
  --     Use Intel IPP Async:         NO
  --     Use VA:                      NO
  --     Use Intel VA-API/OpenCL:     NO
  --     Use Lapack:                  YES (/usr/lib/libopenblas.so)
  --     Use Eigen:                   NO
  --     Use Cuda:                    YES (ver 9.0)
  --     Use OpenCL:                  YES
  --     Use OpenVX:                  NO
  --     Use custom HAL:              NO
  -- 
  --   NVIDIA CUDA
  --     Use CUFFT:                   YES
  --     Use CUBLAS:                  YES
  --     USE NVCUVID:                 NO
  --     NVIDIA GPU arch:             30 35 37 50 52 60 61
  --     NVIDIA PTX archs:
  --     Use fast math:               NO
  -- 
  --   OpenCL:                        &lt;Dynamic loading of OpenCL library&gt;
  --     Include path:                /home/rohit/opencv-3.3.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:                       /home/rohit/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.13.3)
  --     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/java-8-oracle/include /usr/lib/jvm/java-8-oracle/include/linux /usr/lib/jvm/java-8-oracle/include
  --     Java wrappers:               NO
  --     Java tests:                  NO
  -- 
  --   Matlab:                        Matlab not found or implicitly disabled
  -- 
  --   Documentation:
  --     Doxygen:                     NO
  -- 
  --   Tests and samples:
  --     Tests:                       YES
  --     Performance tests:           YES
  --     C/C++ Examples:              YES
  -- 
  --   Install path:                  /usr/local
  -- 
  --   cvconfig.h is in:              /home/rohit/opencv-3.3.0/build
  -- -----------------------------------------------------------------
  -- 
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/rohit/opencv-3.3.0/build
  </code></pre>