c++ - '简历' : a namespace with this name does not exist while building (VS 2015, OpenCV 3.2)

标签 c++ visual-studio opencv

在 VS2015 中构建一个简单的 OpenCV 应用程序时出现错误 'cv': a namespace with this name does not exist while building 虽然我相信我已经完成了为 VS 配置 OpenCV 所需的所有步骤(使用本文作为引用 http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html )

类(class)的开始很简单

#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;

由于 Visual Studio 不会在 #include 上抛出任何错误,我假设 C/C++ -> General -> Additional Include Directories 中的配置是正确的。

在 Linker -> General -> Additional Library Dependencies 我添加了 opencv\build\x64\vc14\build\lib 文件夹。

在 Linker -> Input -> Additional Dependencies 我有以下两个库:

opencv_world320.lib
opencv_world320d.lib

此文件夹中没有其他内容。文件夹 opencv/build/x64/vc14/bin 已添加到 PATH。

感谢任何检查/更改的建议:)

最佳答案

我也遇到过这个问题,解决方案简单得令人抓狂:

#include "stdafx.h"必须是第一个 #include。

OpenCV 人员提供的示例没有提及这一点,即使他们提供了专门使用 visual studio 执行此操作的示例。

关于c++ - '简历' : a namespace with this name does not exist while building (VS 2015, OpenCV 3.2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43015802/

相关文章:

asp.net - 获取未打开的 .aspx 页面中的代码错误

c - “MS Visual Studio快速监视”窗口中的结构布局显示不正确

java - 在Java中将位图转换为mat以进行图像处理

C++ 多态性 + 用于选择返回类型的模板成员函数。怎么做?

visual-studio - SVN 与 TFS 集成

c++ - 如何使用 MFC 在项目的所有对话框中访问变量?

opencv - 为什么 getAffineTransform 返回零矩阵

python - 如何在 OpenCV 中更改图像的透明度?

c++ - 如何使用 SSE 优化矩阵 3 乘 3 的点?

c++ - 在 CUDA 设备代码和主机代码中创建模板类对象时未解析的外部函数