Reputation: 3978
While building a simple OpenCV app in VS2015 I am getting error 'cv': a namespace with this name does not exist while building
while I believe I did all the required steps to configure OpenCV for VS (using this article as reference http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html)
Beginning of the class is very simple
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/stitching.hpp"
#include "opencv2/core/core.hpp"
#include "stdafx.h"
using namespace std;
using namespace cv;
Since Visual Studio doesn't throw any errors on #include I assume the configuration in the C/C++ -> General -> Additional Include Directories is correct.
In Linker -> General -> Additional Library Dependencies I have the opencv\build\x64\vc14\build\lib
folder added.
In Linker -> Input -> Additional Dependencies I have the following two libs:
opencv_world320.lib
opencv_world320d.lib
There is nothing else in this folder. Folder opencv/build/x64/vc14/bin
is added to PATH.
Any suggestions what to check/change is appreciated :)
Upvotes: 4
Views: 7997
Reputation: 921
I had this problem as well, and the solution was maddeningly simple:
The #include "stdafx.h" must be the first #include.
The example that the OpenCV folks provide does not mention this, even when they're providing an example for doing this specifically with visual studio.
Upvotes: 12