“程序无法启动,因为您的计算机中缺少 opencv_world300.dll”C 中的错误

新手上路,请多包涵

我想在 Visual Studio 2013 中编译一个 opencv 控制台 C++ 程序。这是我的代码:

 #include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv)
{
    Mat img = imread("rgb_1.png", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'

    if (img.empty()) //check whether the image is loaded or not
    {
        cout << "Error : Image cannot be loaded..!!" << endl;
        //system("pause"); //wait for a key press
        return -1;
    }

    namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
    imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

    waitKey(0); //wait infinite time for a keypress

    destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

    return 0;
}

尽管我已经在 Computer 和 Visual Studio 目录的属性中定义了所有目录,但出现以下错误:

“程序无法启动,因为您的计算机中缺少 opencv_world300.dll。”

我该如何解决这个问题?

原文由 yusuf 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

在 windows 下,您可以从以下位置复制它:

 <your install directory>\opencv30\build\x64\vc12\bin

并将其放入您的 Visual Studio 解决方案中(我假设您使用的是 x64/Release 配置):

 <your solution directory>\x64\Release

或者你可以将上面的 OpenCV 添加到你的 PATH 环境变量中

原文由 RevJohn 发布,翻译遵循 CC BY-SA 3.0 许可协议

当您没有将相关文件添加到路径变量 重新启动 Visual Studio 时,最常发生这种情况。

我的 opencv_world460.dll 文件位于以下文件夹中: C:\OpenCV-4.6.0\opencv\build\x64\vc14\bin 。我将此添加到我的系统变量 PATH

通常请注意,当您更新路径变量时,您必须重新启动控制台或 Visual Studio。仅当您重新启动控制台或重新启动 Visual Studio 时,才会更新路径变量。

原文由 Dean P 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题