不同DLL的通用运行时 [英] Common runtime for different DLLs

查看:141
本文介绍了不同DLL的通用运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个能够在运行时加载其他DLL的DLL;这些其他DLL与主DLL(这是Python和扩展)有一个非常亲密的关系,所以它们必须有一个通用的运行时。主要的DLL 必须是一个可以简单地复制到目标机器上的文件。辅助DLL将被放置在不同的目录中。

I need to build a DLL capable to load other DLLs at runtime; these other DLLs have a rather intimate relationship with the main DLL (this is Python and extensions), so they must have a common runtime. The main DLL must be a single file that can be simply copied on the target machine. The auxiliary DLLs will be placed in a different directory.

所以:通用运行时是指没有静态链接; 单个文件+简单复制排除了共享的MS可重新分发的东西,特别是当加上不同的目录时。

So: "common runtime" means no static linking; "single file + simple copy" rules out the shared MS redistributables, especially when coupled with "different directories".

我只看到以下选项:将所有DLL链接到 msvcrt.dll ;将当前 msvcrtXX 嵌入主DLL并重新导出其所有符号;使用主机应用程序的 msvcrtXX 。对我来说,第一个看起来最简单,因为这是一个常见的需求,有很多网页解释如何去做。你会如何处理这个?

I only see the following options: link all DLLs against msvcrt.dll; embed current msvcrtXX into the main DLL and re-export all its symbols; use the msvcrtXX of the host application. To me the first looks the simplest, because it's a common need and there are many web pages explaining how to go about it. How would you approach this?

推荐答案

我建议你重新架构,以便你的插件DLL(主机应用程序显式加载)只包含代理功能以及文件管理逻辑。该DLL可以使用静态运行时,或者根本没有运行时。

I suggest you re-architecture so that your plug-in DLL (the one the host application loads explicitly) contains nothing but proxy functions plus the file management logic. This DLL could use a static runtime, or no runtime at all.

将实际功能(特别是需要与Python扩展共享运行时的所有代码)在一个单独的(主要)DLL中,将此DLL以及您所选择的运行时,与Python扩展名相同的目录。

Put the actual functionality (and in particular all code that needs to share a runtime with the Python extensions) in a separate ("primary") DLL and put this DLL, as well as the runtime of your choice, in the same directory as the Python extensions.

主DLL并且运行时可以压缩到插件DLL以及核心扩展。 (我假设这在运行时的可再发行许可证的范围内,因为它基本上与大多数安装人员的工作方式相同,但是您应该检查自己)。

The primary DLL and the runtime could be zipped to the plug-in DLL, along with the core extensions. (I presume this is within the scope of the runtime's redistributable license, since it's basically the same as the way most installers work, but you should check for yourself.)

对插件的调用效率会稍微降低一些,因为它们必须经过代理DLL,但性能差异可能无法衡量。 : - )

The calls to the plug-in will be slightly less efficient since they have to go through the proxy DLL, but the performance difference probably won't be measurable. :-)

这篇关于不同DLL的通用运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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