Repository: opencv
Issue: opencv-2.4.* compilation issue with cuda, bumblebee
Labels: bug,priority: normal,category: build/install,affected: 2.4,category: gpu/cuda (contrib)

Hi

i have an issue and i have searched many forums, maillists for a solution so i believe it is a bug. I have tried to install OpenCV-2.4.11 on my laptop with an integrated Intel videocontroller and a separate NVIDIA Geforce 940M videocontroller. I have installed Cuda  with the capability version 5.0 with the Cuda 7.5 driver and runtimeversion. The repo is the OpenSUSE bumblebee repository with nvidia-bumblebee. I haven't started the bumblebee daemon yet to avoid any troubles that maybe comes with that. When i want to make it with this configuration

```
--     Linker flags (Debug):        
--     Precompiled headers:         YES
-- 
--   OpenCV modules:
--     To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera dynamicuda viz
-- 
--   GUI: 
--     QT 5.x:                      YES (ver 5.4.2)
--     QT OpenGL support:           YES (Qt5::OpenGL 5.4.2)
--     OpenGL support:              YES (/usr/lib64/libGLU.so /usr/lib64/libGL.so /usr/lib64/libSM.so /usr/lib64/libICE.so /usr/lib64/libX11.so /usr/lib64/libXext.so)
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib64/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib64/libjpeg.so (ver )
--     PNG:                         /usr/lib64/libpng.so (ver 1.6.13)
--     TIFF:                        /usr/lib64/libtiff.so (ver 42 - 4.0.4)
--     JPEG 2000:                   /usr/lib64/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib64/libImath.so /usr/lib64/libIlmImf.so /usr/lib64/libIex.so /usr/lib64/libHalf.so /usr/lib64/libIlmThread.so (ver 2.1.0)
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.2)
--     FFMPEG:                      YES
--       codec:                     YES (ver 56.26.100)
--       format:                    YES (ver 56.25.101)
--       util:                      YES (ver 54.20.100)
--       swscale:                   YES (ver 3.1.101)
--       gentoo-style:              YES
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.2.1) / libv4l2 (ver 1.2.1)
--     XIMEA:                       NO
--     Xine:                        YES (ver 1.2.6)
-- 
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   YES (ver 3.2.2)
--     Use TBB:                     NO
--     Use OpenMP:                  YES
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    YES (ver 7.5)
--     Use OpenCL:                  YES
-- 
--   NVIDIA CUDA
--     Use CUFFT:                   YES
--     Use CUBLAS:                  YES
--     USE NVCUVID:                 YES
--     NVIDIA GPU arch:             50
--     NVIDIA PTX archs:
--     Use fast math:               YES
-- 
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/peter/programs/opencv-2.4.11/3rdparty/include/opencl/1.2
--     Use AMD FFT:                 NO
--     Use AMD BLAS:                NO
-- 
--   Python:
--     Interpreter:                 /usr/bin/python2 (ver 2.7.8)
--     Libraries:                   /usr/lib64/libpython2.7.so (ver 2.7.8)
--     numpy:                       /usr/lib64/python2.7/site-packages/numpy/core/include (ver 1.9.0)
--     packages path:               lib/python2.7/site-packages
-- 
--   Java:
--     ant:                         /usr/bin/ant (ver 1.9.4)
--     JNI:                         /usr/lib64/jvm/java/include /usr/lib64/jvm/java/include/linux /usr/lib64/jvm/java/include
--     Java tests:                  YES
-- 
--   Documentation:
--     Build Documentation:         YES
--     Sphinx:                      /usr/bin/sphinx-build (ver 1.2.3)
--     PdfLaTeX compiler:           /usr/bin/pdflatex
--     Doxygen:                     YES (/usr/bin/doxygen)
-- 
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              YES
-- 
--   Install path:                  /usr/local
-- 
--   cvconfig.h is in:              /home/peter/programs/opencv-2.4.11/build
-- -----------------------------------------------------------------
-- 


i get this linking error.

-- Generating done
-- Build files have been written to: /home/peter/programs/opencv-2.4.11/build
[  0%] Built target opencv_core_pch_dephelp
[  0%] Built target pch_Generate_opencv_core
[  3%] Built target opencv_core
[  3%] Built target opencv_ts_pch_dephelp
[  3%] Built target pch_Generate_opencv_ts
[  3%] Built target opencv_flann_pch_dephelp
[  3%] Built target pch_Generate_opencv_flann
[  6%] Built target opencv_flann
[  9%] Built target opencv_imgproc_pch_dephelp
[  9%] Built target pch_Generate_opencv_imgproc
[  9%] Built target opencv_imgproc
[  9%] Automatic moc for target opencv_highgui
[  9%] Built target opencv_highgui_automoc
[  9%] Automatic moc for target opencv_highgui_pch_dephelp
[  9%] Built target opencv_highgui_pch_dephelp_automoc
[ 12%] Built target opencv_highgui_pch_dephelp
[ 12%] Built target pch_Generate_opencv_highgui
[ 12%] Built target opencv_highgui
[ 12%] Built target opencv_features2d_pch_dephelp
[ 12%] Built target pch_Generate_opencv_features2d
[ 12%] Built target opencv_features2d
[ 12%] Built target opencv_video_pch_dephelp
[ 12%] Built target pch_Generate_opencv_video
[ 15%] Built target opencv_video
[ 15%] Built target opencv_ts
[ 15%] Built target opencv_perf_core_pch_dephelp
[ 15%] Built target pch_Generate_opencv_perf_core
Linking CXX executable ../../bin/opencv_perf_core
../../lib/libopencv_core.so.2.4.11: undefined reference to `__cudaRegisterLinkedBinary_52_tmpxft_00004cee_00000000_7_matrix_operations_cpp1_ii_332650c4'
collect2: error: ld returned 1 exit status
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:529: recipe for target 'bin/opencv_perf_core' failed
make[2]: *** [bin/opencv_perf_core] Error 1
CMakeFiles/Makefile2:875: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2
peter@linux-opht:~/programs/opencv-2.4.11/build> 
```

I have found this error and the solution in most time has to do with adding a an nvcc flag called 
rdc=true but adding this to the configuration leads causes another troubles. If i use make -j8 then it swallows the error  and continues building on the other processes. The error appears again at 27% and the making stops at 
27%.

Thx peter