【问题标题】:'cv': a namespace with this name does not exist while building (VS 2015, OpenCV 3.2)'cv':构建时不存在具有此名称的命名空间(VS 2015,OpenCV 3.2)
【发布时间】:2017-03-25 11:30:08
【问题描述】:

在 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

开课很简单

#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++ -> 常规 -> 附加包含目录中的配置是正确的。

在链接器 -> 常规 -> 附加库依赖项中,我添加了 opencv\build\x64\vc14\build\lib 文件夹。

在链接器 -> 输入 -> 附加依赖项中,我有以下两个库:

opencv_world320.lib
opencv_world320d.lib

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

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

【问题讨论】:

  • 当然,您正确包含标题?仔细检查一下,应该有错误的来源。
  • 将#include "opencv2/core/core.hpp" 替换为#include "opencv2/opencv.hpp"' 后,我收到警告"#include "opencv2/opencv.hpp"':查找时已跳过用于预编译头文件”。还有很多与 xtr1common 相关的错误...

标签: c++ visual-studio opencv


【解决方案1】:

我也遇到过这个问题,解决方法非常简单:

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

OpenCV 人员提供的示例并未提及这一点,即使他们提供了专门使用 Visual Studio 执行此操作的示例。

【讨论】:

  • 这对我来说是一样的,这对我有帮助。谢谢。我不敢相信解决方案这么简单。我讨厌 C++
  • 当它像这样愚蠢的时候,这让我很生气。这就是为什么人们讨厌编程,因为那些不明显的愚蠢的小东西。感谢您的提示,现在我的代码可以编译了。
  • 无法在 Visual Studio 2019 中打开源文件#include "stdafx.h" :(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-10-28
  • 1970-01-01
  • 2016-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多