Question Details

No question body available.

Tags

c++ opencv cygwin undefined-reference

Answers (1)

June 9, 2026 Score: 0 Rep: 19,356 Quality: Medium Completeness: 80%

It appears you are mixing OpenCV versions. Your library may be from version 3.4.1, but your compiler found header files from version 4.0 or later. (Maybe OpenCV had previously been installed and you did not realize it?) You'll need the header files from the same version as your library.

In early versions, OpenCV defined its own string type as cv::String. For the 4.0.0 release, this type was dropped in favor of std::string. The type cv::String is still defined, but it is now an alias for std::string. (Keeping the name as an alias meant that it was not necessary to update each place in the code where this type is used.) Since your compiler recorded the signature of your constructor as involving std::string, it apparently had seen this alias in opencv2/core/cvstd.hpp, hence this header is from version 4.0 or later.

In contrast, your library still uses cv::String as a distinct type, so it is from a version prior to 4.0, probably from the version you installed, 3.4.1. This is a version conflict with your headers, which led to your linker error. It might be fortunate that you got a linker error. If the link succeeded, you could end up with bizarre, hard-to-diagnose crashes from the version mismatch.

Check your include paths. You might have two sets of OpenCV headers on your system, one for 3.4.1 and one for version 4.0+. Make sure your compiler finds the 3.4.1 headers. You could also check for libraries in other locations. If you find a second set of OpenCV libraries, upgrading OpenCV might be easier than you thought.