如何链接opencv和其他dll文件输出exe的visual studio 2013 [英] How to link opencv and other dll files to output exe of visual studio 2013

查看:124
本文介绍了如何链接opencv和其他dll文件输出exe的visual studio 2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的视觉工作室,opencv。

I am new with visual studio, opencv.

我为我的项目使用visual studio 2013,opencv和c ++。

I am using visual studio 2013, opencv and c++ for my project.

我已将(复制路径)将opencv和其他库配置到我的计算机环境系统。

I configured (copied path) the opencv and other library to my computer environment system.

视觉工作室,通常在项目中会有一个exe文件。

After run the project in visual studio, normally, there will be an exe file in the project.

我可以复制项目文件夹中的exe文件,

这是因为我的计算机环境系统配置了opencv和其他库。

This is because my computer environment systems are configured with opencv and other library.

我想对其他计算机做同样的事情,但我不想手动配置每个计算机与opencv和其他库。

I want to do the same thing with other computers BUT I do not want to manually configure each computer with opencv and other libraries.

有没有任何方法,我可以做的链接所有在exe文件中运行Visual Studio 2013中的项目后,所以我可以运行exe而不依赖于libaries和opencv的路径。

已编辑

我使用opencv安装程序opencv2.4.7.exe

I use opencv installer opencv2.4.7.exe

在当前的VS2013我的项目,我配置我的项目和opencv安装程序这个链接
http://www.anlak.com/using-opencv-2-4-x-with-visual-studio-2010-tutorial/

In the current VS2013 my project, i configured my project and opencv installer as this link http://www.anlak.com/using-opencv-2-4-x-with-visual-studio-2010-tutorial/

问题:我可以使用文件夹C:\opencv\build\x64\vc11\ staticlib来自opencv安装程序不需要从源opencv创建自己的库?

question : Can i use the library in folder C:\opencv\build\x64\vc11\staticlib come from the opencv installer no need create my own library from source opencv?

问题:如果我需要从opencv生成新库来源( http://docs.opencv.org/doc/tutorials/introduction /windows_install/windows_install.html )或在opencv安装程序的静态文件夹中使用lib,如果我想包括所有的exe文件,我需要创建新的项目和重新配置?

question : In case i need to generate new library from opencv source (http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html) or use lib in static folder of opencv installer, if i want to include it all to exe files, do i need to create new project and reconfigure?

谢谢。

推荐答案

首先需要重建openCV生成静态库而不是动态链接库。这样,您的应用程序使用的所有代码都放在一个单独的exe文件(这可能会显着更大)。这个exe文件,你可以移动到其他计算机,他们应该仍然在那里工作,只要他们有一个至少与你的兼容的架构。因此,如果你在x86 perconal电脑(32位)上构建它,它应该基本上可以在任何其他个人计算机上工作。如果您在x64计算机(AMD 64位)上构建它,它将只运行在其他x64计算机上。至少这是真的假设两个系统使用相同的系统调用API(Windows NT,POSIX ...)。

First you need to rebuild openCV to generate static libraries instead of dynamically linked ones. This way all code that your application uses is thrown together in one single exe-file (which will probably be significantly bigger). This exe-file you can move to other computers and they should still work there, provided they have an architecture that is at least compatible with yours. So if you build it on an x86 perconal computer (32-bit), it should basically work on any other personal computer. If you build it on a x64 computer (AMD 64-bit), it will only run on other x64 machines. At least this is true assuming both systems use the same syscall API (Windows NT, POSIX...).

对于openCV,您可以通过设置BUILD_SHARED_LIBS build标志false(请参见 OpenCV作为静态库(cmake选项),以下行是从那里取得的):

For openCV you do this by setting the BUILD_SHARED_LIBS build flag to false (see OpenCV as a static library (cmake options), the following line is taken from there):


cmake -DBUILD_SHARED_LIBS = OFF ..

cmake -DBUILD_SHARED_LIBS=OFF ..

一旦你这样做,你会看到openCV文件夹看起来非常相似,你现在,除了在你的'lib'文件夹中现在将有.lib文件的.dll文件(至少如果你正在使用Windows,我假设你自从使用Visual Studio)。

Once you have done this, you will see that the openCV folder looks very similar to the one you have now, except that in your 'lib' folder there will now be .lib-files instead of .dll files (at least if you are working on Windows, which I assume you do since you are using Visual Studio).

下一步是去你的项目设置并设置链接器以链接静态库而不是动态库。如果你使用openCV的本地方法进行链接,你可以去项目设置 - > linker - > input - >添加依赖项。在这里你将所有openCV库的扩展名从.dll更改为.lib。

Next step is to go to your project settings and set your linker to link with the static libraries instead of the dynamically ones. If you have used openCV's local method for linking, you can go to project settings -> linker -> input -> Addtional dependencies. There you change the extension of all the openCV libraries from .dll to .lib.

现在你应该可以重新构建你的应用程序,依赖库。

Now you should be able to rebuild your application and the resulting exe-file should have all dependent libraries contained in it.

这篇关于如何链接opencv和其他dll文件输出exe的visual studio 2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆