shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.22k stars 1.13k forks source link

Errors while building OpenCVSharp from source #1668

Closed toita86 closed 1 month ago

toita86 commented 1 month ago

Summary of your issue

Hi, I'm trying to build opencvsharp form source but after building as written on the docs a little bit of problems with the linkage I'm stuck with this errors.

>warpers_cuda.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::remap(class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,int,int,class cv::Scalar_<double>,class cv::cuda::Stream &)" (?remap@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@00HHV?$Scalar_@N@2@AEAVStream@12@@Z)
1>btv_l1_cuda.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::remap(class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,int,int,class cv::Scalar_<double>,class cv::cuda::Stream &)" (?remap@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@00HHV?$Scalar_@N@2@AEAVStream@12@@Z)
1>btv_l1_cuda.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::add(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_InputArray const &,int,class cv::cuda::Stream &)" (?add@cuda@cv@@YAXAEBV_InputArray@2@0AEBV_OutputArray@2@0HAEAVStream@12@@Z)
1>blenders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::add(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_InputArray const &,int,class cv::cuda::Stream &)" (?add@cuda@cv@@YAXAEBV_InputArray@2@0AEBV_OutputArray@2@0HAEAVStream@12@@Z)
1>btv_l1_cuda.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::multiply(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,double,int,class cv::cuda::Stream &)" (?multiply@cuda@cv@@YAXAEBV_InputArray@2@0AEBV_OutputArray@2@NHAEAVStream@12@@Z)
1>btv_l1_cuda.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::addWeighted(class cv::_InputArray const &,double,class cv::_InputArray const &,double,double,class cv::_OutputArray const &,int,class cv::cuda::Stream &)" (?addWeighted@cuda@cv@@YAXAEBV_InputArray@2@N0NNAEBV_OutputArray@2@HAEAVStream@12@@Z)
1>btv_l1_cuda.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::resize(class cv::_InputArray const &,class cv::_OutputArray const &,class cv::Size_<int>,double,double,int,class cv::cuda::Stream &)" (?resize@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@V?$Size_@H@2@NNHAEAVStream@12@@Z)
1>btv_l1_cuda.obj : error LNK2001: unresolved external symbol "struct cv::Ptr<class cv::cuda::Filter> __cdecl cv::cuda::createGaussianFilter(int,int,class cv::Size_<int>,double,double,int,int)" (?createGaussianFilter@cuda@cv@@YA?AU?$Ptr@VFilter@cuda@cv@@@2@HHV?$Size_@H@2@NNHH@Z)
1>seam_finders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::graphcut(class cv::cuda::GpuMat &,class cv::cuda::GpuMat &,class cv::cuda::GpuMat &,class cv::cuda::GpuMat &,class cv::cuda::GpuMat &,class cv::cuda::GpuMat &,class cv::cuda::GpuMat &,class cv::cuda::Stream &)" (?graphcut@cuda@cv@@YAXAEAVGpuMat@12@000000AEAVStream@12@@Z)
1>blenders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::subtract(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_InputArray const &,int,class cv::cuda::Stream &)" (?subtract@cuda@cv@@YAXAEBV_InputArray@2@0AEBV_OutputArray@2@0HAEAVStream@12@@Z)
1>blenders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::compare(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,int,class cv::cuda::Stream &)" (?compare@cuda@cv@@YAXAEBV_InputArray@2@0AEBV_OutputArray@2@HAEAVStream@12@@Z)
1>blenders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::copyMakeBorder(class cv::_InputArray const &,class cv::_OutputArray const &,int,int,int,int,int,class cv::Scalar_<double>,class cv::cuda::Stream &)" (?copyMakeBorder@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@HHHHHV?$Scalar_@N@2@AEAVStream@12@@Z)
1>blenders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::pyrDown(class cv::_InputArray const &,class cv::_OutputArray const &,class cv::cuda::Stream &)" (?pyrDown@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@AEAVStream@12@@Z)
1>blenders.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::pyrUp(class cv::_InputArray const &,class cv::_OutputArray const &,class cv::cuda::Stream &)" (?pyrUp@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@AEAVStream@12@@Z)
1>matchers.obj : error LNK2001: unresolved external symbol "public: static struct cv::Ptr<class cv::cuda::DescriptorMatcher> __cdecl cv::cuda::DescriptorMatcher::createBFMatcher(int)" (?createBFMatcher@DescriptorMatcher@cuda@cv@@SA?AU?$Ptr@VDescriptorMatcher@cuda@cv@@@3@H@Z)
1>frame_source.obj : error LNK2001: unresolved external symbol "struct cv::Ptr<class cv::cudacodec::VideoReader> __cdecl cv::cudacodec::createVideoReader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<int,class std::allocator<int> > const &,struct cv::cudacodec::VideoReaderInitParams)" (?createVideoReader@cudacodec@cv@@YA?AU?$Ptr@VVideoReader@cudacodec@cv@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$vector@HV?$allocator@H@std@@@5@UVideoReaderInitParams@12@@Z)
1>optical_flow.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::merge(class cv::cuda::GpuMat const *,unsigned __int64,class cv::_OutputArray const &,class cv::cuda::Stream &)" (?merge@cuda@cv@@YAXPEBVGpuMat@12@_KAEBV_OutputArray@2@AEAVStream@12@@Z)
1>optical_flow.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::split(class cv::_InputArray const &,class cv::cuda::GpuMat *,class cv::cuda::Stream &)" (?split@cuda@cv@@YAXAEBV_InputArray@2@PEAVGpuMat@12@AEAVStream@12@@Z)
1>optical_flow.obj : error LNK2001: unresolved external symbol "public: static struct cv::Ptr<class cv::cuda::BroxOpticalFlow> __cdecl cv::cuda::BroxOpticalFlow::create(double,double,double,int,int,int)" (?create@BroxOpticalFlow@cuda@cv@@SA?AU?$Ptr@VBroxOpticalFlow@cuda@cv@@@3@NNNHHH@Z)
1>optical_flow.obj : error LNK2001: unresolved external symbol "public: static struct cv::Ptr<class cv::cuda::DensePyrLKOpticalFlow> __cdecl cv::cuda::DensePyrLKOpticalFlow::create(class cv::Size_<int>,int,int,bool)" (?create@DensePyrLKOpticalFlow@cuda@cv@@SA?AU?$Ptr@VDensePyrLKOpticalFlow@cuda@cv@@@3@V?$Size_@H@3@HH_N@Z)
1>optical_flow.obj : error LNK2001: unresolved external symbol "public: static struct cv::Ptr<class cv::cuda::FarnebackOpticalFlow> __cdecl cv::cuda::FarnebackOpticalFlow::create(int,double,bool,int,int,int,double,int)" (?create@FarnebackOpticalFlow@cuda@cv@@SA?AU?$Ptr@VFarnebackOpticalFlow@cuda@cv@@@3@HN_NHHHNH@Z)
1>optical_flow.obj : error LNK2001: unresolved external symbol "public: static struct cv::Ptr<class cv::cuda::OpticalFlowDual_TVL1> __cdecl cv::cuda::OpticalFlowDual_TVL1::create(double,double,double,int,int,double,int,double,double,bool)" (?create@OpticalFlowDual_TVL1@cuda@cv@@SA?AU?$Ptr@VOpticalFlowDual_TVL1@cuda@cv@@@3@NNNHHNHNN_N@Z)
1>input_array_utility.obj : error LNK2001: unresolved external symbol "void __cdecl cv::cuda::cvtColor(class cv::_InputArray const &,class cv::_OutputArray const &,int,int,class cv::cuda::Stream &)" (?cvtColor@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@HHAEAVStream@12@@Z)
1>C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.dll : fatal error LNK1120: 21 unresolved externals
1>Done building project "OpenCvSharpExtern.vcxproj" -- FAILED.

Environment

I'm on a windows machine with win11

What did you do when you faced the problem?

I have tried to give all the possible additional .lib files in the Linker -> Input -> Additional Dependecies but nothing of that worked. I have followed the solution proposed here https://github.com/shimat/opencvsharp/issues/967 but the case is different for me. Sorry to bother @AvenSun, if you have any suggestion I will be happy to try it.

AvenSun commented 1 month ago

@toita86 have you built static library of OpenCV with CUDA successfully? according to the message above, it should be due to wrong library or wrong path of the library given.

toita86 commented 1 month ago

So, I have compiled and I think in a successful manner, here it is the output

Computing installation plan...
The following packages are already installed:
    tesseract:x64-windows-static -> 5.3.1
tesseract:x64-windows-static is already installed
Total install time: 80.3 us
tesseract provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(Tesseract CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Tesseract::libtesseract)

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- Detected processor: AMD64
-- libjpeg-turbo: VERSION = 2.1.3, BUILD = opencv-4.9.0-libjpeg-turbo
-- libjpeg-turbo(SIMD): SIMD extensions disabled: could not find NASM compiler.  Performance will suffer.
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.5.0, BUILD = opencv-4.9.0-openjp2-2.5.0
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
-- found Intel IPP (ICV version): 2021.11.0 [2021.11.0]
-- at: C:/Users/Utente/Documents/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/icv
-- found Intel IPP Integration Wrappers sources: 2021.11.0
-- at: C:/Users/Utente/Documents/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/iw
-- Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (Required is at least version "7.5")
-- NVCUVID: Header not found, WITH_NVCUVID requires Nvidia decoding library header C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/nvcuvid.h
-- NVCUVENC: Header not found, WITH_NVCUVENC requires Nvidia encoding library header C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/nvEncodeAPI.h
-- CUDA: Using CUDA_ARCH_BIN=5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0
-- 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 BLAS (missing: BLAS_LIBRARIES)
-- Could NOT find LAPACK (missing: LAPACK_LIBRARIES)
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Module opencv_alphamat disabled because the following dependencies are not found: Eigen
-- freetype2:   NO
-- harfbuzz:    NO
-- Julia not found. Not compiling Julia Bindings.
-- Module opencv_ovis disabled because OGRE3D was not found
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
-- Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
-- Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
-- Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
-- Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
-- Tesseract:   YES (ver unknown)
-- Allocator metrics storage type: 'long long'
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/Users/Utente/Documents/opencv_files/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/int8layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon_fp16.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_winograd_f63.neon_fp16.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
-- imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326
CMake Warning at C:/Users/Utente/Documents/opencv_files/opencv_contrib/modules/cudacodec/CMakeLists.txt:26 (message):
  cudacodec::VideoReader requires Nvidia Video Codec SDK.  Please resolve
  dependency or disable WITH_NVCUVID=OFF

CMake Warning at C:/Users/Utente/Documents/opencv_files/opencv_contrib/modules/cudacodec/CMakeLists.txt:30 (message):
  cudacodec::VideoWriter requires Nvidia Video Codec SDK.  Please resolve
  dependency or disable WITH_NVCUVENC=OFF

-- highgui: using builtin backend: WIN32UI
-- rgbd: Eigen support is disabled. Eigen is Required for Posegraph optimization
-- Building with NVIDIA Optical Flow API 2.0
--
-- General configuration for OpenCV 4.9.0 =====================================
--   Version control:               4.9.0
--
--   Extra modules:
--     Location (extra):            C:/Users/Utente/Documents/opencv_files/opencv_contrib/modules
--     Version control (extra):     4.9.0
--
--   Platform:
--     Timestamp:                   2024-03-14T16:20:36Z
--     Host:                        Windows 10.0.22631 AMD64
--     CMake:                       3.29.0-rc3
--     CMake generator:             Visual Studio 17 2022
--     CMake build tool:            C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
--     MSVC:                        1939
--     Configuration:               Debug 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 (14 files):         + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (8 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (34 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (5 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe  (ver 19.39.33520.0)
--     C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP  /O2 /Ob2 /DNDEBUG
--     C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP  /Zi /Ob0 /Od /RTC1
--     C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe
--     C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP   /O2 /Ob2 /DNDEBUG
--     C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP /Zi /Ob0 /Od /RTC1
--     Linker flags (Release):      /machine:x64  /NODEFAULTLIB:atlthunk.lib /INCREMENTAL:NO  /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib
--     Linker flags (Debug):        /machine:x64  /NODEFAULTLIB:atlthunk.lib /debug /INCREMENTAL  /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib
--     ccache:                      NO
--     Precompiled headers:         YES
--     Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/cudart_static.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppial.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppc.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppitc.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppig.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppist.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppidei.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/cublas.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/cublasLt.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/cufft.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppicc.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppif.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/nppim.lib
--     3rdparty dependencies:       ittnotify libprotobuf libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib ippiw ippicv
--
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    datasets gapi java_bindings_generator js_bindings_generator objc_bindings_generator python_bindings_generator python_tests world
--     Disabled by dependency:      -
--     Unavailable:                 alphamat cannops cvv freetype hdf java julia matlab ovis python2 python3 sfm ts viz
--     Applications:                -
--     Documentation:               NO
--     Non-free algorithms:         YES
--
--   Windows RT support:            NO
--
--   GUI:                           WIN32UI
--     Win32 UI:                    YES
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.3)
--     JPEG:                        build-libjpeg-turbo (ver 2.1.3-62)
--       SIMD Support Request:      YES
--       SIMD Support:              NO
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.2.0)
--     JPEG 2000:                   build (ver 2.5.0)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
--
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES (prebuilt binaries)
--       avcodec:                   YES (58.134.100)
--       avformat:                  YES (58.76.100)
--       avutil:                    YES (56.70.100)
--       swscale:                   YES (5.9.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   NO
--     DirectShow:                  YES
--     Media Foundation:            YES
--       DXVA:                      YES
--
--   Parallel framework:            Concurrency
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Intel IPP:                   2021.11.0 [2021.11.0]
--            at:                   C:/Users/Utente/Documents/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/icv
--     Intel IPP IW:                sources (2021.11.0)
--               at:                C:/Users/Utente/Documents/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/iw
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
--     Flatbuffers:                 builtin/3rdparty (23.5.9)
--
--   NVIDIA CUDA:                   YES (ver 12.3.107, CUFFT CUBLAS)
--     NVIDIA GPU arch:             50 52 60 61 70 75 80 86 89 90
--     NVIDIA PTX archs:            90
--
--   cuDNN:                         NO
--
--   OpenCL:                        YES (NVD3D11)
--     Include path:                C:/Users/Utente/Documents/opencv_files/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python (for build):            C:/Users/Utente/AppData/Local/Microsoft/WindowsApps/python3.exe
--
--   Install to:                    C:/Users/Utente/Documents/opencv_files/build_win_x64/install
-- -----------------------------------------------------------------
--
-- Configuring done (5.0s)
-- Generating done (1.3s)
-- Build files have been written to: C:/Users/Utente/Documents/opencv_files/build_win_x64

There are a couple of warning but I don't know if they are the cause of my problem. The VC++ include dir are $(CUDA_PATH)\include;C:\Users\Utente\Documents\opencvsharp\include;$(IncludePath) the library dir i have set are

$(CUDA_PATH)\lib\x64;C:\Users\Utente\Documents\opencvsharp\modules\core\opencv_core.dir\Release;
C:\Users\Utente\Documents\opencvsharp\modules\stitching\opencv_stitching.dir\Release;
C:\Users\Utente\Documents\opencvsharp\modules\superres\opencv_superres.dir\Release;
C:\dev\vcpkg\installed\x64-windows-static\lib;
C:\Users\Utente\Documents\opencvsharp\x64\vc17\staticlib;
$(LibraryPath)

I'm new to visual studio and usually don't develop for win. Let me know if I did something wrong @AvenSun

AvenSun commented 1 month ago

@toita86

everything looks correct if you built solution successfully.

by the way, since you have enabled CUDA, it would be advisable to enable CUDNN as well via WITH_CUDNN.

libraries listed below are needed when WITH_CUDA and WITH_CUDNN enabled.

cuda.lib
cudart_static.lib
nppc.lib
nppial.lib
nppicc.lib
nppidei.lib
nppif.lib
nppig.lib
nppim.lib
nppist.lib
nppisu.lib
nppitc.lib
npps.lib
cublas.lib
cufft.lib
cudnn.lib

you should append these files to Additional Dependencies of project OpenCvSharpExtern,

image

and make sure the path including these libraries have been set correctlly. the path looks like below.

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\11.8\lib\x64

image

then you can try building the project again.

toita86 commented 1 month ago

Thank you for the reply @AvenSun, I appreciate the help. I have added the flag for CUDNN, in the linker -> input -> Additional Dependecies I have added this .lib files

cudart.lib
cublas.lib
cublasLt.lib
cuda.lib
cudadevrt.lib
cudart_static.lib
cudnn.lib
cudnn64_9.lib
cudnn_adv.lib
cudnn_adv64_9.lib
cudnn_cnn.lib
cudnn_cnn64_9.lib
cudnn_engines_precompiled.lib
cudnn_engines_precompiled64_9.lib
cudnn_engines_runtime_compiled.lib
cudnn_engines_runtime_compiled64_9.lib
cudnn_graph.lib
cudnn_graph64_9.lib
cudnn_heuristic.lib
cudnn_heuristic64_9.lib
cudnn_ops.lib
cudnn_ops64_9.lib
cufft.lib
cufftw.lib
cufilt.lib
curand.lib
cusolver.lib
cusolverMg.lib
cusparse.lib
nppc.lib
nppial.lib
nppicc.lib
nppidei.lib
nppif.lib
nppig.lib
nppim.lib
nppist.lib
nppisu.lib
nppitc.lib
npps.lib
nvblas.lib
nvJitLink.lib
nvJitLink_static.lib
nvjpeg.lib
nvml.lib
nvptxcompiler_static.lib
nvrtc-builtins_static.lib
nvrtc.lib
nvrtc_static.lib
OpenCL.lib

but i still get the errors, is it possible to be the fault of the NVIDIA Video Codec SDK? Its a warning in the out put log of the opencv building but I'm not sure that is the fault.

AvenSun commented 1 month ago

@toita86 actually there's no need to add all libraries of CUDA && CUDNN.

files listed above is enough to run OpenCV DNN with CUDA enabled.

Additional Dependecies should not only include CUDA && CUDNN files but also the OpenCV libraries enabled and needed.

it might be like below according to your log motioned above.

opencv_aruco490.lib
opencv_bgsegm490.lib
opencv_bioinspired490.lib
opencv_calib3d490.lib
opencv_ccalib490.lib
opencv_core490.lib
opencv_cudaarithm490.lib
opencv_cudabgsegm490.lib
opencv_cudacodec490.lib
opencv_cudafeatures2d490.lib
opencv_cudafilters490.lib
opencv_cudaimgproc490.lib
opencv_cudalegacy490.lib
opencv_cudaobjdetect490.lib
opencv_cudaoptflow490.lib
opencv_cudastereo490.lib
opencv_cudawarping490.lib
opencv_cudev490.lib
opencv_dnn490.lib
opencv_dnn_objdetect490.lib
opencv_dnn_superres490.lib
opencv_dpm490.lib
opencv_face490.lib
opencv_features2d490.lib
opencv_flann490.lib
opencv_fuzzy490.lib
opencv_hfs490.lib
opencv_highgui490.lib
opencv_img_hash490.lib
opencv_imgcodecs490.lib
opencv_imgproc490.lib
opencv_intensity_transform490.lib
opencv_line_descriptor490.lib
opencv_mcc490.lib
opencv_ml490.lib
opencv_objdetect490.lib
opencv_optflow490.lib
opencv_phase_unwrapping490.lib
opencv_photo490.lib
opencv_plot490.lib
opencv_quality490.lib
opencv_rapid490.lib
opencv_reg490.lib
opencv_rgbd490.lib
opencv_saliency490.lib
opencv_shape490.lib
opencv_stereo490.lib
opencv_stitching490.lib
opencv_structured_light490.lib
opencv_superres490.lib
opencv_surface_matching490.lib
opencv_text490.lib
opencv_tracking490.lib
opencv_video490.lib
opencv_videoio490.lib
opencv_videostab490.lib
opencv_wechat_qrcode490.lib
opencv_xfeatures2d490.lib
opencv_ximgproc490.lib
opencv_xobjdetect490.lib
opencv_xphoto490.lib
IlmImf.lib
ippicvmt.lib
ippiw.lib
ittnotify.lib
libopenjp2.lib
libjpeg-turbo.lib
libpng.lib
libprotobuf.lib
libtiff.lib
libwebp.lib
quirc.lib
zlib.lib
ws2_32.lib
cudart_static.lib
nppc.lib
nppial.lib
nppicc.lib
nppidei.lib
nppif.lib
nppig.lib
nppim.lib
nppist.lib
nppisu.lib
nppitc.lib
npps.lib
cublas.lib
cudnn.lib
cufft.lib
cuda.lib

then you can have a try.

toita86 commented 1 month ago

Perfect, thank you @AvenSun, the linkage error is not showing anymore! Now I have this error relative to the copy. Here it is the log(let me know if you need the full compilation log):

4>   Creating library C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.lib and object C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.exp
4>Generating code
4>Previous IPDB not found, fall back to full compilation.
4>All 14688 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
4>Finished generating code
4>OpenCvSharpExtern.vcxproj -> C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.dll
4>        1 file(s) copied.
4>        1 file(s) copied.
4>The system cannot find the path specified.
4>The system cannot find the path specified.
4>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: The command "copy "C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\dll\x64\OpenCvSharpExtern.dll"
4>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: copy "C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\OpenCvSharpExtern.dll"
4>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: copy "C:\Users\Utente\Documents\opencvsharp\opencv_files\opencv490_win_x64\x64\vc17\bin\opencv_videoio_ffmpeg490_64.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\opencv_videoio_ffmpeg490_64.dll"
4>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: copy "C:\Users\Utente\Documents\opencvsharp\opencv_files\opencv490_win_x64\x64\vc17\bin\opencv_videoio_ffmpeg490_64.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\dll\x64\opencv_videoio_ffmpeg490_64.dll"
4>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code 1.
4>Done building project "OpenCvSharpExtern.vcxproj" -- FAILED.
AvenSun commented 1 month ago

@toita86 This issue is caused by UAC. The destination path is on the C drive. Visual Studio lacks write permissions for the directory unless running VS as Admin. or just copy these files manually.

toita86 commented 1 month ago

@AvenSun Sorry, but I don't get it. I'm running VS as Administrator but I have the same output. I have copied manually just the opencv_videoio_ffmpeg490_64.dll but no success on the compilation. The OpenCvSharpExtern.dll was already there. I'm sure I'm missing something. My directories now look like this: Tests x64

AvenSun commented 1 month ago

@toita86

Done building project "OpenCvSharpExtern.vcxproj" -- FAILED.

If the project OpenCvSharpExtern compilation failed, you shouldn't be able to get the DLL files.

actually this message was caused by the failure of post build event.

as you can see, there're several lines command about copy.

image

copy "C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\dll\x64\OpenCvSharpExtern.dll"
copy "C:\Users\Utente\Documents\opencvsharp\src\Release\x64\OpenCvSharpExtern.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\OpenCvSharpExtern.dll"
copy "C:\Users\Utente\Documents\opencvsharp\opencv_files\opencv490_win_x64\x64\vc17\bin\opencv_videoio_ffmpeg490_64.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\opencv_videoio_ffmpeg490_64.dll"
copy "C:\Users\Utente\Documents\opencvsharp\opencv_files\opencv490_win_x64\x64\vc17\bin\opencv_videoio_ffmpeg490_64.dll" "C:\Users\Utente\Documents\opencvsharp\test\OpenCvSharp.Tests\dll\x64\opencv_videoio_ffmpeg490_64.dll"

so you can clear this post build event and copy manually, or modify copy command correctly.

toita86 commented 1 month ago

Thank you very much for the help @AvenSun, I really appreciate the time you spent to help me.

I have just one last question how I can use this built version of OpenCvSharp in my project? I need to add a reference to dlls? Its not a procedure of which I have a clear understanding. Sorry if its a basic question.

AvenSun commented 1 month ago

@toita86

you're welcome!

to use your own build, there's no need to add package of OpenCvSharp4.runtime.win via Nuget.

just copy OpenCvSharpExtern.dll and opencv_videoio_ffmpeg490_64.dll to corresponding place.

that's it.

toita86 commented 1 month ago

@AvenSun I have copied the files in the folder of the project. But it does not work. console app

AvenSun commented 1 month ago

@toita86 there's no need to add native library via Nuget. but you're still need to add managed wrapper OpenCvSharp4 via Nuget.

toita86 commented 1 month ago

@AvenSun I have downloaded via Nuget only OpenCvSharp4 as you said but I have the error shown below, its not seeing the .dll file. console app debug console app

AvenSun commented 1 month ago

@toita86 some DLLs needed might not be in your system path. you can check the missing library of OpenCvSharpExtern.dll via dependency walker. then just copy these libraries to system path or same directory of your app.

toita86 commented 1 month ago

@AvenSun I'm starting to think that I have produced every possible error in this process XD. Anyway I'm facing this things in the dependency walker reports:

I don't have a lot of knowledge on this so I don't really know what to do

AvenSun commented 1 month ago

@toita86

generally you can just copy the missing libraries within the first level of node

somthing looks like the attached image below (marked with yellow)

image

toita86 commented 1 month ago

@AvenSun I'm really sorry but I don't understand how to do it, can you give me some step by step instructions? Dep Walker VS Console app As you can see I have tried to copy all the first level dlls to the root of the project, but no running success.

AvenSun commented 1 month ago

@toita86

image

the native OpenCvExtern.dll was built in 64bit, so make sure your console app was built in AnyCPU or 64 bit.

you can find this setting in property of console project.

toita86 commented 1 month ago

@AvenSun, I was able to get it to work after i have moved all the dll in the folder in bin/x64/debug/net8.0 the set the build configuration in debug and x64 as you said and I get the build information as wanted.

Thank you a lot for the help! I'm really grate full.

AvenSun commented 1 month ago

glad to hear that. you're welcome.

aloksharma1 commented 4 weeks ago

@toita86 hello i am trying to build opencvsharp for gpu too, i have completed step 1 & 2, opencv is built with cuda, opencvextern is built and create dll,pdb,lib & exp files. now whats the next step for it, i am unable to compile opencvsharp project, how do i link it all?