如何通过visual studio构建一个可移植的程序 [英] How to build a portable program by visual studio
问题描述
我在 Win7-64bit 下使用 Visual Studio 2010 用 openCV 构建应用程序.我完成了开发并构建了发布版本,没有错误.我也在调试模式下成功运行了程序.然后我将 .exe
文件移动到同一台计算机中的其他目录.我在 cmd.exe
中运行它,但出现错误 warning: Error opening file <../../modules/highgui/src/cap_ffmpeg_implhpp:537>
我想对某些 openCV 库有一些依赖性,但我不知道如何解决它.我的最终任务是我可以直接在 Win7 下的另一台计算机上使用该 .exe
.怎么做?
我在此处发现了一个类似的问题.但是我没有建立.dll
文件,我该怎么做才能解决这个问题?
I am using visual studio 2010 under Win7-64bit to build an application with openCV. I finished development and build the release version without error. I also successfully run the program in debug mode. I then move the .exe
file to other directory in the same computer. I run it in cmd.exe
and I got error warning: Error opening file <../../modules/highgui/src/cap_ffmpeg_implhpp:537>
I guess there are some dependence with some libraries of openCV but I don't how to solve it. My final task is that I can use that .exe
in another computer under Win7 directly. How to do it?
I found a similar question here. But I don't have .dll
file built, so what should I do to solve this problem?
推荐答案
使用共享库 (DLL) 构建 OpenCV 应用程序需要 DLL 可用于 exe
运行时.
Building an OpenCV app with shared libs (DLLs) require the DLLs to be available (same folder or in lookup path) to the exe
when it is run.
如果您使用静态链接,则不需要任何 OpenCV DLL 即可访问.然而,由于许可问题,ffmpeg 是动态链接的,即使其他库都是静态链接的,因此,您需要为 提供 ffmpeg DLL代码>exe.它被称为 opencv_ffmpeg*.dll
之类的东西.
If you are using static linking then you don't need any of the OpenCV DLLs to be reachable. However, due to licensing issues, ffmpeg is linked dynamically even when the rest of the libs are linked statically, and thus, you need to have the ffmpeg DLL available for the exe
. It is called something like opencv_ffmpeg*.dll
.
请注意,仅当您使用 highgui
相关功能时才需要这样做.
Note that this is only needed if you are using highgui
related functionality.
这篇关于如何通过visual studio构建一个可移植的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!