Open CV C++ Unresolved External Symbol Mat

I downloaded the windows library for open cv and ran the setup which copied the open cv files to a folder named open cv on my computer. I then opened the folder and found two folders inside namely “build” and “sources”. I added the include folder in build to my Visual Studio C++ include directory and added the lib folder in “build/x64/vc16/lib” to the library directory of Visual Studio C++ Library directories. When I attempt to run my program, it throws a Linker error that the external symbol “public: class cv::Mat” is unresolved. How do I make the linker link these libraries successfully to get rid of the error l, Thank You.

great !
but you also have to add an actual library to link
(not only the folder !)

the prebuilt windows pack has an opencv_world(d).lib, which should be added to your project’s ‘Additional link libraries’ (with ‘d’ for debug, without for release)

last (just saying…), you also need to add build/x64/vc16/bin to the PATH, so your prog finds the dll at runtime

Yes I have understood that in addition to adding the required include and lib folders to VC++ directories we also need to point the lib folder to the linker and specify a library input. I have attempted to run the program but am not getting this exception opencv_world470d.dll was not found. I added the bin folder in the folder to environment path variables. What am i doing wrong, Thanks. The PATH for open cv works because am able to detect the version of open cv from the command line using opencv_version command.

Can i add the dll to my project and add it as a dependency?

This will work, most likely you added it to your system environmental vars which requires a restart or you didn’t restart visual studio.


for a list of possibilities.

1 Like

I restarted my machine and the program is still throwing the same error

Which folder did you add to your path environmental variable?

I added the bin folder in this path “build/x64/vc16/bin” to the system variables, which works when I call opencv_version on a sample terminal window. But the program does not see the dll

I would guess it works because you are inside the build/x64/vc16/bin directory when you call opencv_version.exe.

What is the full path to the folder containing opencv_world470d.dll?

I fixed it by pasting the dll in the same folder where the exe of the C++ program is. The script detects the edges on the image and saves the output to disk with the function cv::imwrite. I am now trying to detect shapes using cv::findCountours which accepts a contour parameter that is the equivalent of the class VectorOfVectorOfPoint in C# Emgu Cv. What is the equivalent of that type in C++

I would not recommend this, if you rebuild OpenCV using a more recent commit you can errors related to the face that opencv_world470d.dll in your program directory can have a different ABI to the one in your build directory.

This is off topic, you should start a new thread.

1 Like