Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'cv': a namespace with this name does not exist while building (VS 2015, OpenCV 3.2)

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 :)

like image 799
Lech Migdal Avatar asked Dec 14 '22 23:12

Lech Migdal


1 Answers

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.

like image 143
Aaron Averett Avatar answered Apr 09 '23 00:04

Aaron Averett