Multiple errors installing OpenCV from source files

Hi, I am new to OpenCV and trying to install it from source files using Cmake(gui) and Visual Studio 2017.

System Properties

Windows 10 Enterprise Version 1709 OS Build 16299.2166
GPU = Nvidia Quadro P600 (Driver version 452.77)
CMake 3.19.2
Cuda Toolkit Version 10.1
Microsoft Visual Studio Professional 2017 Version 15.9.31
OpenCV 4.5.0 (extra modules downloaded from Github are the latest version)
Visual Toolkit version 7.1

Cmake
After altering a few configurations in Cmake (Generator = Visual Studio 15 2017, Platform = x64)

  • WITH_CUDA = TRUE
  • OPOENCV_EXTRA_MODULES_PATH = …/opencv_contrib-master/modules
  • BUILD_EXAMPLES = TRUE)
    I configure again before generating (log is at Cmake Configuration - Pastebin.com)

Compiling in Visual Studio
I proceed to run OpenCV.sln in Visual Studio and after building either BUILD_ALL or INSTALL in the x64 Debug configuration, I get 13176 Warnings and 391 Errors.
For the sake of brevity, I will only put unique errors on this post but the full error lists (warnings here: OpenCV Visual Studio Warnings - Pastebin.com and errors here: pastebin->GTa6mTgp (new users can only post 2 links))

Warnings

  • Unreachable code
  • The -std=c++ 11 flag is not supported with the configured host compiler. Flag will be removed
  • potentially uninitialized local variable ‘rmsd’ used
  • nonstandard extension used: nameless struct/union
  • field of class type without a DLL interfaced used with a DLL interface
  • base class dllexport/dllimport specification differs from that of the derived class
  • assignment with conditional expression
  • ‘|’ unsafe mix of type ‘int’ and type ‘bool’ in operation
  • ___ unreferenced local function has been removed
  • conversion from ___ to ___ possible loss of data
  • ‘detail’ namespace uses itself
  • signed/unsigned mismatch

Errors

  • syntax error: missing ‘;’ before ‘vocabulary’
  • missing type specifier - ‘int’ assumed. Note: C++ does not support default-int
  • cannot open include file: ‘opencv2/video/detail/tracking.private.hpp’: No such file or directory
  • cannot open file ‘…\lib\Debug\opencv_tracking450d.lib’
  • cannot open file ‘…\lib\Debug\opencv_stereo450d.lib’
  • binary ‘->’: no operator found which takes left-hand operand of type ‘cv::Ptr’ (or there is no acceptable conversion)
  • ‘vocabulary’: undeclared identifier
  • ‘TrackerKCF/GOTURN/CSRT’ is not a class or namespace name
  • ‘Tracker’: base class undefined
  • ‘string’ undeclared identifier
  • ‘Params’: ambiguous symbol
  • ‘cv::tracking::::’ method with override specifier ‘override’ did not override any base class methods
  • ‘cv::Ptr’ class has no constructors
  • ‘cv::Ptr’: ‘Tracker’ is not a valid template type argument for parameter ‘T’
  • ‘create’: identifier not found

Any help would be appreciated thanks.

Did you copy opencv_contrib in opencv ?

C:/Users/byan982/softwarehere/opencv/opencv_contrib-master/modules

Cmake Configuration - Pastebin.com line 122

where is that “quote” from?

there is no copying involved. setting OPOENCV_EXTRA_MODULES_PATH = …/opencv_contrib-master/modules is precisely how to handle the situation.
`

I would suggest using cmake-gui.

please post complete cmake output from configuration step.

reduce the problem. look at the error messages to judge what modules give you trouble. switch off those modules. rebuild. then enable them individually and rebuild again.

Hi, I have updated the Cmake output (from the gui) in pastebin: Cmake Configuration - Pastebin.com

To clarify, I made a folder named ‘opencv’ so the path to opencv would be C:/Users/byan982/softwarehere/opencv/opencv/build.

I managed to build INSTALL without any errors (x64, Release) after disabling python3 and the tracking module. I will continue testing to see what is and is not working.

if your build succeeds without the tracking module, that’s progress! the rest of the errors are likely caused by the one issue. the python module depends on all other configured modules so it will fail if anything else failed before it.

where did you get those sources from? acceptable sources:

  • github.com/opencv/opencv and opencv_contrib, but DO check out a version tag, not simply the master branch. the master branches may not be in sync, and they may contain code that isn’t release quality.
  • release package from opencv.org

you must not mix both source trees. recommended layout:

  • (some arbitrary directory)
    • opencv/
      • modules/, build/, …
    • opencv_contrib/
      • modules/, …

The release package was downloaded from the opencv website (as stated above, but I cannot have links in this reply) . I got the extra modules from github/opencv/opencv_contrib by downloading the files as a .zip, which might have been the cause of the issues.

I am using the recommended layout as above and have not mixed the source trees.

I have built RUN_TESTS (also in Release,x64) which failed to build, passing 35/120 tests (visual studio output with pastebin code: mVFSGPf9). Notably, calib3d exited with code 0xc0000374 rather than passing or failing, which probably caused the build to fail. I am also not sure how many modules may have required the tracking module to pass the tests, which I assume heavily influenced these results.