opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

Build error in cudacodec

Open cwlm opened this issue 5 days ago • 3 comments

I'm trying to build opencv on Ubuntu 24.04 with cmake 4.2, gcc 14.2.0, cuda 13.1. opencv commit bd54424f03ac541be7ec54aed89b85a007838f6d opencv_contrib commit b02762329b8533f0a722b996585bc51a9baaa682

the last commit I'm able to build is 945c8a5298f8ea50445c6b121efc59a9d398f106 using the following commands

cmake -B build \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv/opencv_contrib/modules \
    -D WITH_CUDA=ON \
    -D WITH_CUDNN=ON \
    -D CUDA_ARCH_BIN=8.9 \
    -D WITH_FFMPEG=ON \
    -D WITH_GSTREAMER=ON \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D WITH_EIGEN=ON \
    -D BUILD_EXAMPLES=ON \
    -D ENABLE_FAST_MATH=ON \
    -D OPENCV_IPP_ENABLE_ALL=ON \
    -D WITH_IPP=ON \
    -D WITH_OPENMP=ON \
    -D WITH_GTK=ON \
    -D ENABLE_CUDA_FIRST_CLASS_LANGUAGE=ON \
    -D OPENCV_DNN_OPENVINO=ON
cd build
make -j$(nproc)

it failed during compiling cudacodec:

In file included from /home/cwlm/opencv/opencv_contrib/modules/cudacodec/src/precomp.hpp:57,
                 from /home/cwlm/opencv/opencv_contrib/modules/cudacodec/src/NvEncoder.cpp:4:
/home/cwlm/opencv/opencv/modules/core/include/opencv2/core/private.cuda.hpp:60:12: fatal error: cuda.h: No such file or directory
   60 | #  include <cuda.h>
      |            ^~~~~~~~
compilation terminated.
-- General configuration for OpenCV 4.13.0-dev =====================================
--   Version control:               4.12.0-400-g927beeacf6
-- 
--   Extra modules:
--     Location (extra):            /home/cwlm/opencv/opencv_contrib/modules
--     Version control (extra):     4.12.0-64-gb0276232
-- 
--   Platform:
--     Timestamp:                   2025-12-07T19:05:57Z
--     Host:                        Linux 6.6.87.2-microsoft-standard-WSL2 x86_64
--     CMake:                       4.2.0
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/gmake
--     Configuration:               Release
--     Algorithm Hint:              ALGO_HINT_ACCURATE
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (19 files):         + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       AVX (10 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16
--       AVX2 (39 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3
--       AVX512_SKX (10 files):     + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3 AVX_512F AVX512_COMMON AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 14.2.0)
--     C++ flags (Release):         -fsigned-char -ffast-math -fno-finite-math-only -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -ffast-math -fno-finite-math-only -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -ffast-math -fno-finite-math-only -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -ffast-math -fno-finite-math-only -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
--     Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          /usr/local/cuda-13.1/targets/x86_64-linux/lib/libcudart.so dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec 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 java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape signal stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cannops cvv fastcv julia matlab ovis python2 sfm
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         YES
-- 
--   GUI:                           GTK3
--     GTK+:                        YES (ver 3.24.41)
--     VTK support:                 YES (ver 9.1.0)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.3)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver decoder: 0x0209, encoder: 0x020f, demux: 0x0107)
--     AVIF:                        NO
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.43)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 4.5.1 / 4.5.1)
--     JPEG 2000:                   OpenJPEG (ver 2.5.0)
--     OpenEXR:                     OpenEXR::OpenEXR (ver 3.1.5)
--     GIF:                         YES
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     FFMPEG:                      YES
--       avcodec:                   YES (60.31.102)
--       avformat:                  YES (60.16.100)
--       avutil:                    YES (58.29.100)
--       swscale:                   YES (7.5.100)
--       avdevice:                  YES (60.3.100)
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            OpenMP
-- 
--   Trace:                         YES (with Intel ITT(3.25.4))
-- 
--   Other third-party libraries:
--     Intel IPP:                   2022.2.0 [2022.2.0]
--            at:                   /home/cwlm/opencv/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2022.2.0)
--               at:                /home/cwlm/opencv/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
--     VA:                          NO
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.4.0)
--     Custom HAL:                  YES (ipp (ver 0.0.1))
--     Protobuf:                    build (3.19.1)
--     Flatbuffers:                 builtin/3rdparty (25.9.23)
-- 
--   NVIDIA CUDA:                   YES (ver 13.1.80, CUFFT CUBLAS)
--     NVIDIA GPU arch:             89
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         YES (ver 9.14.0)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/cwlm/opencv/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.12.3)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.12.so (ver 3.12.3)
--     Limited API:                 NO
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.26.4)
--     install path:                lib/python3.12/dist-packages/cv2/python-3.12
-- 
--   Python (for build):            /usr/bin/python3
-- 
--   Java:                          
--     ant:                         NO
--     Java:                        YES (ver 21.0.9)
--     JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
--     Java wrappers:               YES (JAVA)
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------

cwlm avatar Dec 07 '25 19:12 cwlm