“程序无法启动,因为您的计算机缺少 opencv_world300.dll”C++ 中的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31711093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"The program can't start because opencv_world300.dll is missing from your computer" error in C++
提问by yusuf
I want to compile an opencv Console C++ program in Visual Studio 2013. This is my code:
我想在 Visual Studio 2013 中编译一个 opencv Console 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;
}
Although I have defined all the directories in properties both in Computer and Visual Studio directories, I get the following error:
虽然我已经在 Computer 和 Visual Studio 目录中的属性中定义了所有目录,但我收到以下错误:
"The program can't start because opencv_world300.dll is missing from your computer."
“程序无法启动,因为您的计算机缺少 opencv_world300.dll。”
How can I fix this problem?
我该如何解决这个问题?
采纳答案by RevJohn
Under windows you can copy it from:
在 Windows 下,您可以从以下位置复制它:
<your install directory>\opencv30\build\x64\vc12\bin
And put it in your Visual Studio solution (I assume you are using a x64/Releaseconfiguration):
并将其放入您的 Visual Studio 解决方案中(我假设您使用的是x64/Release配置):
<your solution directory>\x64\Release
Or you you can add the above OpenCV to your PATH environment variable
或者您可以将上述 OpenCV 添加到您的 PATH 环境变量中
回答by luckyging3r
I had the same problem.
我有同样的问题。
I'm on version 320
. Once all your environment variables are set make sure your Additional Include Directories
, Additional Library Directories
and Additional Dependencies
are all correct. For me they were $(OPENCV_BUILD)\include;
, $(OPENCV_BUILD)\x64\vc14\lib;
and opencv_world320d.lib;
respectively.
我在版本上320
。一旦设置了所有环境变量,请确保您的Additional Include Directories
,Additional Library Directories
和Additional Dependencies
都是正确的。对我来说,他们是$(OPENCV_BUILD)\include;
,$(OPENCV_BUILD)\x64\vc14\lib;
和opencv_world320d.lib;
分别。
My OPENCV_BUILD
path variable is C:\opencv320\build
setting the environment variable to %OPENCV_BUILD%\x64\vc14\bin
(where the .dll files are located). To get to the Additional
things right-click on your project/solution and select properties -> C/C++
for the first and properties -> Linker -> General
and Input
for the other two.
我的OPENCV_BUILD
路径变量C:\opencv320\build
将环境变量设置为%OPENCV_BUILD%\x64\vc14\bin
(.dll 文件所在的位置)。去的Additional
东西放在你的项目/解决方案右键单击并选择properties -> C/C++
第一和properties -> Linker -> General
和Input
其他两个。
Restart Visual Studioand if everything was implemented correctly then you should be able to run the program and it should start.
重新启动 Visual Studio,如果一切都正确实现,那么您应该能够运行该程序并且它应该会启动。
Edit:
编辑:
Depending on what you used I had to also switch mine from x86
to x64
in the Solution Platforms
dropdown.
根据您使用的内容,我还x86
必须x64
在Solution Platforms
下拉列表中将我的从 切换到。
回答by Fish Chang
You can check your system variable to confirm the directory in which opencv_world300.dll
is located (maybe C:\opencv\build\x64\vc12\bin
) is present.
您可以检查您的系统变量以确认所在的目录 opencv_world300.dll
(可能C:\opencv\build\x64\vc12\bin
)存在。
If it exists but the problem still is not solved, try to put all .dll
files in the directory to C:\WINDOWS\system32
如果存在但问题仍未解决,尝试将.dll
目录中的所有文件放到C:\WINDOWS\system32
回答by Abhiroop Tandon
If this question is still relevant, I figured out the way.
如果这个问题仍然相关,我想出了办法。
I presume you used the tutorial on the OpenCV
website to setup OpenCV
. Once you run the command prompt and execute the command, it creates the environment variable for OpenCV
but it does not add it in the path. So if you go to the path and add the location of the bin in vc12 (vc14 for me), save it, and restart visual studio, it works.
我想你使用OpenCV
网站上的教程来设置OpenCV
. 运行命令提示符并执行命令后,它会为其创建环境变量,OpenCV
但不会将其添加到路径中。因此,如果您转到路径并在vc12(我是vc14)中添加bin的位置,保存它,然后重新启动visual studio,它就可以工作了。
回答by Strange
Best and simple solution is
最好和简单的解决方案是
Add path_variable of OpenCV/build/x64/bin in environment system variables.
And then restart the visual studio.
在环境系统变量中添加 OpenCV/build/x64/bin 的 path_variable。
然后重启visual studio。
this definitely will solve the problem.
这肯定会解决问题。
the problem might be you've updated the path variable after opening the visual studio so it can't update the *.dll files.
问题可能是您在打开 Visual Studio 后更新了路径变量,因此它无法更新 *.dll 文件。
回答by Tommy Mertell
I know this an old post but I noticed that mine has a problem distinguishing between lib
and bin
, so I added both to the PATH variable and it worked.
我知道这是一篇旧帖子,但我注意到我的在区分lib
and 时有问题bin
,所以我将两者都添加到了 PATH 变量中并且它起作用了。
回答by Andrew H
After installing OpenCV version 3.4.1 for use with VS 2017 following these instructions, Visual Studio complained about missing opencv_world341d.dll
. Even though I had added C:\opencv\build\x64\vc15\bin
to the windows PATH, Visual Studio still couldn't find it as VS was already open when I modified the PATH. Restarting Visual Studio fixed the problem.
按照这些说明安装 OpenCV 版本 3.4.1 以与 VS 2017 一起使用后,Visual Studio 抱怨缺少opencv_world341d.dll
. 即使我已经添加C:\opencv\build\x64\vc15\bin
到 windows PATH,Visual Studio 仍然找不到它,因为当我修改 PATH 时 VS 已经打开。重新启动 Visual Studio 解决了该问题。
回答by Cristi.Fatu
Add the paths as everybody says and keep in mind to restart the Visual Studio. I added all the paths, even tried to copy all the opencv_world.dllin the same folder as the source file, all i had to do was to restart the Visual Studio after i added all the paths.
添加每个人说的路径,并记住重新启动 Visual Studio。我添加了所有路径,甚至尝试将所有opencv_world.dll复制到与源文件相同的文件夹中,我所要做的就是在添加所有路径后重新启动 Visual Studio。
回答by Acimaz
I just had the exact same problem using version 320. In my case my "Comodo Internet Security" was blocking a few things of the application itself and of OpenCV. Make sure to put them all on the "trusted" list by right clicking on them in your firewall.
我只是在使用 320 版本时遇到了完全相同的问题。就我而言,我的“Comodo Internet Security”阻止了应用程序本身和 OpenCV 的一些内容。通过在防火墙中右键单击它们,确保将它们全部放在“受信任”列表中。
回答by NAMRATA AGRAWAL
In visual studio 2019, TRY THIS Add missing file opencv_world430.dll or opencv_worldd.dll in the debug directory of the project where your project application exe file is there. copy & paste missing files in the debug folder
在 Visual Studio 2019 中,尝试在项目应用程序 exe 文件所在的项目的调试目录中添加缺少的文件 opencv_world430.dll 或 opencv_worldd.dll。在调试文件夹中复制和粘贴丢失的文件
C:\Users\myname\source\repos\myopencv\x64\Debug + add your missing file here
C:\Users\myname\source\repos\myopencv\x64\Debug + 在此处添加丢失的文件
my problem got solved in microsoft visual studio 2019 :)
我的问题在 microsoft Visual Studio 2019 中得到解决:)