问题描述
我正在尝试使用 OpenCV 的基本程序,代码如下:
#include "cv.h"#include "highgui.h"int main(){IplImage* newImg;newImg = cvLoadImage("~/apple.bmp", 1);cvNamedWindow("窗口", 1);cvShowImage("窗口", newImg);cvWaitKey(0);cvDestroyWindow("窗口");cvReleaseImage(&newImg);返回0;}
当我运行这个时,我得到
<块引用>程序无法启动,因为您的系统中缺少 libcxcore200.dll计算机.尝试重新安装程序来解决这个问题.
但是,我可以看到这个 DLL.它存在.我已将以下内容添加到链接器的输入依赖项
<块引用>C:OpenCV2.0liblibcv200.dll.aC:OpenCV2.0liblibcvaux200.dll.aC:OpenCV2.0liblibcxcore200.dll.aC:OpenCV2.0liblibhighgui200.dll.a
什么给?我使用的是 Visual Studio 2008.
当我链接 .dll 文件而不是 .dll.a 文件时,我得到 p><块引用>
致命错误 LNK1107:无效或损坏文件:无法在 0x3F8 处读取libcv200.dll
我按照 上的说明进行操作http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010 但仍然卡在完全相同的问题上,所以这是我解决它的方法.
获取 MSVC 2010 速成版.
获取 Win 32 OpenCV 2.2 二进制文件并安装在默认位置.
创建了新项目.
项目设置
项目 -> OpenCV_Helloworld 属性...配置属性 -> VC++ 目录
包含目录...添加:
C:OpenCV2.2include;
库目录...添加:
C:OpenCV2.2lib;C:OpenCV2.2in;
源目录...添加:
C:OpenCV2.2modulescalib3dsrc;C:OpenCV2.2modulescontribsrc;C:OpenCV2.2modulescoresrc;C:OpenCV2.2modulesfeatures2dsrc;C:OpenCV2.2modulesflannsrc;C:OpenCV2.2modulesgpusrc;C:OpenCV2.2modulesgpusrc;C:OpenCV2.2moduleshighguisrc;C:OpenCV2.2modulesimgprocsrc;C:OpenCV2.2moduleslegacysrc;C:OpenCV2.2modulesmlsrc;C:OpenCV2.2modulesobjdetectsrc;C:OpenCV2.2modulesvideosrc;
链接器 -> 输入 -> 附加依赖项...
对于调试版本...添加:
opencv_calib3d220d.lib;opencv_contrib220d.lib;opencv_core220d.lib;opencv_features2d220d.lib;opencv_ffmpeg220d.lib;opencv_flann220d.lib;opencv_gpu2220d.guid2open20d.cvopen220d.lib2opend20d.cvopen220d.cvopen220d.lib2opend20d.opencv_objdetect220d.lib;opencv_video220d.lib;
此时我以为我已经完成了,但是在调试模式下运行exe时遇到了您描述的问题.看到最后一步就很明显了,选择:
链接器 -> 常规 ... 将使用库依赖项输入"设置为是"
希望这会有所帮助.
I am trying just a basic program with OpenCV with the following code:
#include "cv.h"
#include "highgui.h"
int main()
{
IplImage* newImg;
newImg = cvLoadImage("~/apple.bmp", 1);
cvNamedWindow("Window", 1);
cvShowImage("Window", newImg);
cvWaitKey(0);
cvDestroyWindow("Window");
cvReleaseImage(&newImg);
return 0;
}
When I run this, I get
The program can't start because libcxcore200.dll is missing from your computer. Try reinstalling the program to fix this problem.
However, I can see this DLL. It exists. I have added the following to the input dependencies for my linker
C:OpenCV2.0liblibcv200.dll.a C:OpenCV2.0liblibcvaux200.dll.a C:OpenCV2.0liblibcxcore200.dll.a C:OpenCV2.0liblibhighgui200.dll.a
What gives? I'm using visual studio 2008.
When I link the .dll files instead of .dll.a files, I get
fatal error LNK1107:invalid or corrupt file: cannot read at 0x3F8 libcv200.dll
I followed instructions on http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010 but was still stuck on exactly the same problem, so here's how I resolved it.
Fetched MSVC 2010 express edition.
Fetched Win 32 OpenCV 2.2 binaries and installed in default location.
Created new project.
Project setup
Project -> OpenCV_Helloworld Properties...Configuration Properties -> VC++ Directories
Include Directories... add:
C:OpenCV2.2include;
Library Directories... add:
C:OpenCV2.2lib;C:OpenCV2.2in;
Source Directories... add:
C:OpenCV2.2modulescalib3dsrc;C:OpenCV2.2modulescontribsrc;C:OpenCV2.2modulescoresrc;C:OpenCV2.2modulesfeatures2dsrc;C:OpenCV2.2modulesflannsrc;C:OpenCV2.2modulesgpusrc;C:OpenCV2.2modulesgpusrc;C:OpenCV2.2moduleshighguisrc;C:OpenCV2.2modulesimgprocsrc;C:OpenCV2.2moduleslegacysrc;C:OpenCV2.2modulesmlsrc;C:OpenCV2.2modulesobjdetectsrc;C:OpenCV2.2modulesvideosrc;
Linker -> Input -> Additional Dependencies...
For Debug Builds... add:
opencv_calib3d220d.lib;opencv_contrib220d.lib;opencv_core220d.lib;opencv_features2d220d.lib;opencv_ffmpeg220d.lib;opencv_flann220d.lib;opencv_gpu220d.lib;opencv_highgui220d.lib;opencv_imgproc220d.lib;opencv_legacy220d.lib;opencv_ml220d.lib;opencv_objdetect220d.lib;opencv_video220d.lib;
At this point I thought I was done, but ran into the problem you described when running the exe in debug mode. The final step is obvious once you see it, select:
Linker -> General ... Set 'Use Library Dependency Inputs' to 'Yes'
Hope this helps.
这篇关于OpenCV - DLL 丢失,但不是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!