I get “Unresolved external symbol” error when trying to build a C++ project with OpenCV and CUDA

I am trying to build a C++ project with OpenCV 3.4.20 that’s built with CUDA 11.6.2 on Visual Studio 2022 and on Windows 10. But, a few seconds after I begin to build the project, I see several errors such as this:

LNK2001 unresolved external symbol "int __cdecl cv::countNonZero(class cv::debug_build_guard::_InputArray const &)" (?countNonZero@cv@@YAHAEBV_InputArray@debug_build_guard@1@@Z)   

System Specifications:

  • Windows 10

  • Visual Studio 2022

  • OpenCV 3.4.20 (built with CUDA and opencv_contrib modules)

  • CUDA 11.6.2

  • System variables are such as these:

    • CUDA_PATH = C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6
    • CUDA_PATH_V11.6 = C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6
    •           PATH = C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6bin
                       C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6lib
                       C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6libx64
                       C:UsersRITopencv-3.4buildbin
                       C:UsersRITopencv-3.4buildlib
      
      
  • Relevant lines from TheopenCVProject.vcxproj file:

    • Under PropertyGroup Label=”Globals”:

      • <CudaToolkitCustomDir>C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6</CudaToolkitCustomDir>
    • Under ImportGroup Label=”ExtensionSettings”:

      • <Import Project="$(VCTargetsPath)BuildCustomizationsCUDA 11.6.props" />
    • Under PropertyGroup Condition=”‘$(Configuration)|$(Platform)’==’Release|x64′”:

      • <IncludePath>C:UsersRITopencv-3.4buildinstallinclude;$(IncludePath)</IncludePath>
      • <LibraryPath>C:UsersRITopencv-3.4buildinstallx64vc17lib;$(LibraryPath)</LibraryPath>
    • Under ItemDefinitionGroup Condition=”‘$(Configuration)|$(Platform)’==’Release|x64′”

      • <AdditionalIncludeDirectories>C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

      • <AdditionalDependencies>opencv_cudabgsegm3420.lib;npps.lib;nppial.lib;nppicc.lib;nppidei.lib;nppif.lib;nppig.lib;nppim.lib;nppist.lib;nppisu.lib;nppitc.lib;nppc.lib;Gdiplus.lib;opencv_bgsegm3420.lib;opencv_videoio3420.lib;opencv_cudalegacy3420.lib;opencv_video3420.lib;opencv_core3420.lib;opencv_highgui3420.lib;cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;cublas.lib;%(AdditionalDependencies)</AdditionalDependencies>

      • <AdditionalLibraryDirectories>C:UsersRITopencv-3.4buildinstallx64vc17lib;C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6libx64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

      • Under CudaCompile:

        • <CodeGeneration>compute_86,sm_86</CodeGeneration>
        • <AdditionalLibraryDirectories>C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6libx64;C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6bincrt;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

Notes:

  1. There are two folders under Users except Default and Public: RIT is the folder in which opencv, opencv_contrib and the folder of the project I want to build is located. The other one RİT is the default one with all the directories you might expect from a regular User directory such as AppData, Documents and Downloads are located.
  2. When I check opencv folders I can see that all needed libraries are there and I can see that the functions subject of errors are both declared and defined in their respective .cpp, .h and .hpp files.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật