I want to compile an opencv Console C++ program in Visual Studio 2013. This is my code:
#include \"stdafx.h\"
#include \"opencv2/highgui/highgui.hpp\"
#inclu
I know this an old post but I noticed that mine has a problem distinguishing between lib
and bin
, so I added both to the PATH variable and it worked.
Add the paths as everybody says and keep in mind to restart the Visual Studio. I added all the paths, even tried to copy all the opencv_world.dll in the same folder as the source file, all i had to do was to restart the Visual Studio after i added all the paths.
In visual studio 2019, TRY THIS Add missing file opencv_world430.dll or opencv_worldd.dll in the debug directory of the project where your project application exe file is there. copy & paste missing files in the debug folder
C:\Users\myname\source\repos\myopencv\x64\Debug + add your missing file here
my problem got solved in microsoft visual studio 2019 :)
If this question is still relevant, I figured out the way.
I presume you used the tutorial on the OpenCV
website to setup OpenCV
. Once you run the command prompt and execute the command, it creates the environment variable for OpenCV
but it does not add it in the path. So if you go to the path and add the location of the bin in vc12 (vc14 for me), save it, and restart visual studio, it works.
Under windows you can copy it from:
<your install directory>\opencv30\build\x64\vc12\bin
And put it in your Visual Studio solution (I assume you are using a x64/Release configuration):
<your solution directory>\x64\Release
Or you you can add the above OpenCV to your PATH environment variable
I had the same problem.
I'm on version 320
. Once all your environment variables are set make sure your Additional Include Directories
, Additional Library Directories
and Additional Dependencies
are all correct. For me they were $(OPENCV_BUILD)\include;
, $(OPENCV_BUILD)\x64\vc14\lib;
and opencv_world320d.lib;
respectively.
My OPENCV_BUILD
path variable is C:\opencv320\build
setting the environment variable to %OPENCV_BUILD%\x64\vc14\bin
(where the .dll files are located). To get to the Additional
things right-click on your project/solution and select properties -> C/C++
for the first and properties -> Linker -> General
and Input
for the other two.
Restart Visual Studio and if everything was implemented correctly then you should be able to run the program and it should start.
Edit:
Depending on what you used I had to also switch mine from x86
to x64
in the Solution Platforms
dropdown.