将多个DLL组合成1 [英] Combine multiple DLL's into 1

查看:197
本文介绍了将多个DLL组合成1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将多个DLL组合成1.我正在使用一个依赖于许多动态链接库的C ++项目,所以可以将它们组合成1个DLL文件,如果那么我该怎么办?

解决方案

理论上说,如果你想要的不够好,你可以做一些拆卸所有的东西,然后将所有的单独的文件重新组合成对象文件,然后将这些对象文件重新链接成一个大的DLL。实际上这样做通常是不平凡的 - 尽管有可能是像冲突的符号名称这样的东西,这将需要大量的工作来解决。



更清洁的可能性是将所有DLL打包成zip文件(或任何您喜欢的),并且有一个小程序将其解压缩到临时目录,运行主程序,然后从该目录中删除DLL。这有一些自己的问题(例如,如果机器在运行过程中崩溃/失去电源,则保留文件副本)。



编辑:由于您有源代码,所以使用它将所有代码构建到单个DLL中是更加合理的。在大多数情况下,只需将所有源文件添加到创建一个DLL作为其输出的单个项目。你可能(很容易)遇到一些符号冲突。在访问源代码之前,处理这个问题的明显方法是把东西放入命名空间。


I'm wondering if it's possible to combine multiple DLL's into 1. I'm currently working on a C++ project that is dependent on many dynamic link libraries,so would it be possible to combine them into 1 DLL file, and if so, how would I do that?

解决方案

Realistically, no. In theory, if you wanted to badly enough you could do something like disassembling all of them, then re-assembling all the separate files into object files, then re-linking those object files into one big DLL. Getting this to actually work would usually be non-trivial though -- there are likely to be things like conflicting symbol names that would require considerable work to get around.

A rather cleaner possibility would be to package all the DLLs into a zip file (or whatever you prefer) and have a small program to unzip them to a temporary directory, run the main program, and then erase the DLLs from that directory. This has a few problems of its own though (e.g., leaving copies of the files if the machine crashes/loses power/whatever during a run).

Edit: Since you have the source code, using it to build all the code into a single DLL is much more reasonable. For the most part, it's just a matter of adding all the source files to a single project that creates one DLL as its output. You may (easily) run into some symbol conflicts. Given access to the source code, the obvious way to deal with this would be by putting things into namespaces.

这篇关于将多个DLL组合成1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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