c++ - OpenCV 3.4.0 - 未找到 zlibd1.dll

标签 c++ opencv dll visual-studio-2017

我有以下程序,与this tutorial page for OpenCV 3.4.0相同.我在装有 Windows 10 企业版 64 位系统的 64 位笔记本电脑上使用 Visual Studio 2017 Community。

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    if( argc != 2)
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], IMREAD_COLOR); // Read the file

    if( image.empty() ) // Check for invalid input
    {
        cout << "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
    imshow( "Display window", image ); // Show our image inside it.

    waitKey(0); // Wait for a keystroke in the window
    return 0;
}

通过为这个项目设置包含和链接器目录和库,解决方案构建得很好。但是当我运行程序时,出现以下错误:

“代码执行无法继续,因为未找到 zlibd1.dll。重新安装程序可能会解决此问题。”

根据我的初步研究,它不一定来自 Visual Studio 2017。当我尝试创建一个新项目时,我没有选择“Win32 控制台应用程序”的选项。本源码所在项目类型为Visual C++下的Windows Console Application,支持.NET Framework 4.5。

我在这里错过了什么?

根据教程,我应该只使用 OpenCV 3.4.0 提供的库和动态链接库。我记得有一次使用 NuGET 尝试再次安装 OpenCV 3.4.0,as explained here ,当我试图从 OpenCV 3.4.0 本身的文件中解决关于 fopen 的编译器错误时。

最佳答案

好吧,显然这是关于我的系统路径的问题。它设置不正确,之前,我的路径变量设置如下:

%OPENCV_DIR%\lib
%OPENCV_DIR%\bin

$(OPENCV_DIR) 只是 OpenCV 3.4.0 的构建目录。

但是那里的目录不存在,因此找不到库。所以,我用这个替换了它们:

%OPENCV_DIR%\x64\vc15\bin
%OPENCV_DIR%\x64\vc15\lib

程序现在运行了。我当时在想什么?

无论哪种方式,需要注意的重要教训:当您收到一条弹出消息说程序无法打开,因为缺少一个库,并且是 OpenCV 3.4.0 的一部分时,请确保您的系统Windows 10系统高级设置中的path是一个存在的OpenCV目录。

关于c++ - OpenCV 3.4.0 - 未找到 zlibd1.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48431086/

相关文章:

dll - 导出的函数符号名称修改

c++ - clang++ 总是生成空的 profraw 覆盖率报告

opencv - 用于在实际项目开发之前进行特征检测(SIFT 等)原型(prototype)制作的 OpenCV GUI 版本?

c# - 在 Unity 中使用 OpenCVSharp 进行眼睛检测(fps 问题)

c++ - OpenCV2代码链接错误

c++ - 在 MessageBox husing 句柄中显示 dll 的路径

c++ - typedef struct 与 struct - ‘struct' 的存储大小未知

c++ - include "file.h"vs <file> 有什么区别?

c++ - 修复由于 OpenSSL 中的 SIGILL 而导致的崩溃

delphi - 基于TInterfacedClass的Delphi插件框架的内存管理