首页 > 解决方案 > 无法与 opencv 库链接

问题描述

我尝试将 OpenCV 与 Visual Studio 2017 一起使用并运行此示例代码给了我构建时间错误

我已经为库提供了正确的目录。我已经多次阅读有关堆栈溢出的许多教程和问题/答案,但未能成功解决问题。

#include "opencv2\opencv.hpp"
#include "opencv2\core.hpp"
#include "pch.h"
#include "opencv2\core\core.hpp"

using namespace cv;

int main(int argv, char** argc)
{
    Mat test = imread("lena.jpg", IMREAD_UNCHANGED);
    imshow("tst", test);
    waitKey();
}

我收到以下错误

C2065 'IMREAD_UNCHANGED':undeclared identifier
C3861 'imread': identifier not found
C3861 'imshow': identifier not found
C3861 'waitkey': identifier not found

Intellisense 在我键入代码时为我提供了所有库建议,但在构建后会引发错误。

标签: opencvvisual-c++opencv4

解决方案


推荐阅读