Unable to build Opencv 4.5.1 with contrib modules with CUDA ON

I am unable to build Opencv 4.5.1 from source with Contrib modules. Tracing the build error in terminal looks like this:
[ 13%] Building CXX object modules/cudev/CMakeFiles/opencv_cudev.dir/src/stub.cpp.o
[ 13%] Linking CXX shared library …/…/lib/libopencv_cudev.so
[ 13%] Building CXX object modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/conditioning.cc.o
[ 13%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfIO.cpp.o
/usr/bin/ld: cannot find -lfalse
/usr/bin/ld: cannot find -lfalse
collect2: error: ld returned 1 exit status
modules/cudev/CMakeFiles/opencv_cudev.dir/build.make:98: recipe for target β€˜lib/libopencv_cudev.so.4.5.1’ failed
make[2]: *** [lib/libopencv_cudev.so.4.5.1] Error 1
CMakeFiles/Makefile2:4140: recipe for target β€˜modules/cudev/CMakeFiles/opencv_cudev.dir/all’ failed
make[1]: *** [modules/cudev/CMakeFiles/opencv_cudev.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…

My cmake command looks like this:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_C_COMPILER=/usr/bin/gcc-6 \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D WITH_TBB=OFF \
-D WITH_CUDA=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.1 \
-D BUILD_opencv_cudacodec=OFF \
-D BUILD_SHARED_LIBS=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_V4L=OFF \
-D WITH_QT=OFF \
-D WITH_OPENGL=OFF \
-D WITH_GSTREAMER=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D OPENCV_ENABLE_NONFREE=OFF \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_nppicom_LIBRARY=false \
-D HAVE_opencv_python3=OFF \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/home/user/Videos/opencv_contrib-4.5.1/modules \
-D CUDA_ARCH_BIN="${CUDA_ARCH_BIN}" \
-D BUILD_TIFF=OFF \
-D BUILD_EXAMPLES=OFF ..

After successfully generating the configuration, the result:
> -D CMAKE_C_COMPILER=/usr/bin/gcc-6
> -D CMAKE_INSTALL_PREFIX=/usr/local
> -D INSTALL_C_EXAMPLES=OFF
> -D WITH_TBB=OFF
> -D WITH_CUDA=ON
> -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.1
> -D BUILD_opencv_cudacodec=OFF
> -D BUILD_SHARED_LIBS=ON
> -D ENABLE_FAST_MATH=1
> -D CUDA_FAST_MATH=1
> -D WITH_CUBLAS=1
> -D WITH_V4L=OFF
> -D WITH_QT=OFF
> -D WITH_OPENGL=OFF
> -D WITH_GSTREAMER=ON
> -D OPENCV_GENERATE_PKGCONFIG=ON
> -D OPENCV_PC_FILE_NAME=opencv.pc
> -D OPENCV_ENABLE_NONFREE=OFF
> -D WITH_CUDNN=ON
> -D OPENCV_DNN_CUDA=ON
> -D CUDA_nppicom_LIBRARY=false
> -D HAVE_opencv_python3=OFF
> -D ENABLE_PRECOMPILED_HEADERS=OFF
> -D OPENCV_EXTRA_MODULES_PATH=/home/user/Videos/opencv_contrib-4.5.1/modules
> -D CUDA_ARCH_BIN="${CUDA_ARCH_BIN}"
> -D BUILD_TIFF=OFF
> -D BUILD_EXAMPLES=OFF …
– Detected processor: x86_64
– Looking for ccache - not found
– Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version β€œ1.2.11”, minimum required is β€œ1.2.3”)
Cleaning INTERNAL cached variable: TIFF_LIBRARY
Cleaning INTERNAL cached variable: TIFF_INCLUDE_DIR
– Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
Cleaning INTERNAL cached variable: WEBP_LIBRARY
Cleaning INTERNAL cached variable: WEBP_INCLUDE_DIR
– Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
– OpenJPEG: VERSION = 2.3.1, BUILD = opencv-4.5.1-openjp2-2.3.1
– OpenJPEG libraries will be built from sources: libopenjp2 (version β€œ2.3.1”)
– Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version β€œ1.2.11”)
– found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
– at: /home/user/Videos/opencv-4.5.1/release/3rdparty/ippicv/ippicv_lnx/icv
– found Intel IPP Integration Wrappers sources: 2020.0.0
– at: /home/user/Videos/opencv-4.5.1/release/3rdparty/ippicv/ippicv_lnx/iw
– CUDA detected: 11.1
– CUDA NVCC target flags: -D_FORCE_INLINES
– Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
– Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
– Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
– Could NOT find Pylint (missing: PYLINT_EXECUTABLE)
– Could NOT find Flake8 (missing: FLAKE8_EXECUTABLE)
– VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
– OpenCV Python: during development append to PYTHONPATH: /home/user/Videos/opencv-4.5.1/release/python_loader
– Checking for module β€˜libavresample’
– No package β€˜libavresample’ found
– Caffe: NO
– Protobuf: NO
– Glog: YES
– freetype2: YES (ver 21.0.15)
– harfbuzz: YES (ver 1.7.2)
– Julia not found. Not compiling Julia Bindings.
– Module opencv_ovis disabled because OGRE3D was not found
– CERES support is disabled. Ceres Solver for reconstruction API is required.
– Tesseract: YES (ver 4.1.0)
– Allocator metrics storage type: β€˜long long’
– Registering hook β€˜INIT_MODULE_SOURCES_opencv_dnn’: /home/user/Videos/opencv-4.5.1/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
– rgbd: CERES support is disabled. Ceres Solver is Required for Posegraph optimization
– CERES support is disabled. Ceres Solver for reconstruction API is required.
–
– General configuration for OpenCV 4.5.1 =====================================
– Version control: unknown
–
– Extra modules:
– Location (extra): /home/user/Videos/opencv_contrib-4.5.1/modules
– Version control (extra): unknown
–
– Platform:
– Timestamp: 2021-03-04T17:33:25Z
– Host: Linux 4.15.0-132-generic x86_64
– CMake: 3.20.0-rc2
– 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 AVX512_SKX
– requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
– SSE4_1 (17 files): + SSSE3 SSE4_1
– SSE4_2 (2 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 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
– AVX512_SKX (7 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
–
– C/C++:
– Built as dynamic libs?: YES
– C++ standard: 11
– C++ Compiler: /usr/bin/c++ (ver 7.5.0)
– C++ flags (Release): -fsigned-char -ffast-math -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 -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
– C++ flags (Debug): -fsigned-char -ffast-math -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 -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
– C Compiler: /usr/bin/gcc-6
– C flags (Release): -fsigned-char -ffast-math -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 -Wno-comment -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
– C flags (Debug): -fsigned-char -ffast-math -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 -Wno-comment -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
– Linker flags (Release): -Wl,–exclude-libs,libippicv.a -Wl,–exclude-libs,libippiw.a -Wl,–gc-sections -Wl,–as-needed
– Linker flags (Debug): -Wl,–exclude-libs,libippicv.a -Wl,–exclude-libs,libippiw.a -Wl,–gc-sections -Wl,–as-needed
– ccache: NO
– Precompiled headers: NO
– Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc false nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-11.1/lib64 -L/usr/lib/x86_64-linux-gnu
– 3rdparty dependencies:
–
– OpenCV modules:
– To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python2 python3 quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
– Disabled: cudacodec world
– Disabled by dependency: -
– Unavailable: cnn_3dobj cvv java julia matlab ovis viz
– Applications: tests perf_tests apps
– Documentation: NO
– Non-free algorithms: NO
–
– GUI:
– GTK+: YES (ver 3.22.30)
– GThread : YES (ver 2.56.4)
– GtkGlExt: NO
– VTK support: NO
–
– Media I/O:
– ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
– JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
– WEBP: build (ver encoder: 0x020f)
– PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
– TIFF: build (ver 42 - 4.0.10)
– JPEG 2000: build (ver 2.3.1)
– OpenEXR: build (ver 2.3.0)
– HDR: YES
– SUNRASTER: YES
– PXM: YES
– PFM: YES
–
– Video I/O:
– DC1394: YES (2.2.5)
– FFMPEG: YES
– avcodec: YES (56.60.100)
– avformat: YES (56.40.101)
– avutil: YES (54.31.100)
– swscale: YES (3.1.101)
– avresample: NO
– GStreamer: YES (1.14.5)
–
– Parallel framework: pthreads
–
– Trace: YES (with Intel ITT)
–
– Other third-party libraries:
– Intel IPP: 2020.0.0 Gold [2020.0.0]
– at: /home/user/Videos/opencv-4.5.1/release/3rdparty/ippicv/ippicv_lnx/icv
– Intel IPP IW: sources (2020.0.0)
– at: /home/user/Videos/opencv-4.5.1/release/3rdparty/ippicv/ippicv_lnx/iw
– Lapack: NO
– Eigen: YES (ver 3.3.4)
– Custom HAL: NO
– Protobuf: build (3.5.1)
–
– NVIDIA CUDA: YES (ver 11.1, CUFFT CUBLAS FAST_MATH)
– NVIDIA GPU arch:
– NVIDIA PTX archs:
–
– cuDNN: YES (ver 8.0.5)
–
– OpenCL: YES (no extra features)
– Include path: /home/user/Videos/opencv-4.5.1/3rdparty/include/opencl/1.2
– Link libraries: Dynamic load
–
– Python 2:
– Interpreter: /usr/bin/python2.7 (ver 2.7.17)
– Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.17)
– numpy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.1)
– install path: lib/python2.7/dist-packages/cv2/python-2.7
–
– Python 3:
– Interpreter: /usr/bin/python3 (ver 3.6.9)
– Libraries: NO
– numpy: /home/user/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.18.0)
– install path: -
–
– Python (for build): /usr/bin/python2.7
–
– Java:
– ant: NO
– JNI: /usr/lib/jvm/java-8-openjdk-amd64/include /usr/lib/jvm/java-8-openjdk-amd64/include/linux /usr/lib/jvm/java-8-openjdk-amd64/include
– Java wrappers: NO
– Java tests: NO
–
– Install to: /usr/local
– -----------------------------------------------------------------
–
– Configuring done
– Generating done
– Build files have been written to: /home/user/Videos/opencv-4.5.1/release

I am so confused that /usr/bin/ld: cannot find -lfalse error points to not finding libfalse but I couldn’t find any library like this after hours of Googling. Please help.

that’s the problem. it shouldn’t be like that. I believe that’s a string value, not a boolean value.

Hi,
it should be ON or OFF but not false. Something is wrong here
Remove this variable

it’s not a boolean. the cmake stuff handles it like a string that names a library, not like a boolean.

OP is following bad advice that can be found on some blogs that write junk for ad revenue.

1 Like

Thanks for the replies guys. Removing the line solves the build issue, neither ON or OFF works for this parameter.