如何在exe中包含所有dll? [英] How to include all dll's in exe?

查看:475
本文介绍了如何在exe中包含所有dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio 12项目;用C ++编写的源代码;这是一个OpenCV项目.我想将编译后的程序提供给其他人,但是,在其他PC上,我收到有关缺少某些dll的错误消息.我的程序使用许多OpenCV(也许不仅是)dll. 如何解决该问题? 也许在VS 12中可以选择将所有dll都包含在.exe中? 这是一个非常相似的问题,没有适当的答案: 在Visual Studio c ++ 2008中包含dll

I have a Visual Studio 12 project; source code written in C++; it's an OpenCV project. I want to give my compiled program to someone else, but, on other PC, I getting an error message about missing some dlls. My program using many OpenCV (maybe, not only) dll's. How can I resolve that problem? Maybe in VS 12 available an option to include all dll's in .exe? It's a pretty similar question without proper answer: include dlls in visual studio c++ 2008

推荐答案

DLL本身不能静态链接"到可执行文件中;完全违背了他们的目的(嗯,实际上,您可以使用一些非常奇怪的伏都教徒的技巧来真正地做到这一点,但这既不值得推荐,也不必在问这个问题时尝试).

DLLs themself can not be "statically linked" into an executable; that completely defies their purpose (well, actually you can use some really weird voodoo tricks to actually do it, but this is neither recommendable nor should you try it if you have to ask this question).

简单的解决方案是识别程序所需的所有DLL(仅在Debugger中启动程序会生成一个列出所有DLL的日志文件),然后将这些DLL复制到EXE所在的同一目录中.实际上,带有EXE文件的目录也是系统在默认配置下前进到标准系统目录之前,系统在其中查找DLL的第一个目录.打包并以这种方式分发.

The simple solution would be to identify all the DLLs your program requires (just starting the program in the Debugger will generate a log file listing them all) and copy those DLLs into the same directory as the EXE resides in; as it happens the directory with the EXE file in is also the first directory where the system looks for DLLs before advancing to the standad system directoris in default configuration. Package it up and distribute it that way.

这篇关于如何在exe中包含所有dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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