[英]Dll dependency version conflict
I am using C++ with Visual Studio 2008 Express. 我在Visual Studio 2008 Express中使用C ++。
We are supplying a binary-only Windows library to a client, which itself uses a number of other libraries. 我们正在向客户端提供仅二进制的Windows库,该客户端本身使用许多其他库。 Therefore we shipped both our dll file, along with the dll files that we use. 因此,我们运送了我们的dll文件以及我们使用的dll文件。 Now the issue is that our client uses some of the libraries that we also use, but in another version. 现在的问题是,我们的客户端使用了我们也使用的某些库,但是使用了另一个版本。 Therefore he can not use our library, since the libraries we both depend on are incompatible. 因此,他不能使用我们的库,因为我们俩都依赖的库不兼容。
Technically I think it should be possible that both dependency versions are loaded into the process space. 从技术上讲,我认为两个依赖版本都可以加载到进程空间中。 However, I am unsure how to do this, as both their application, as well as our dll look for the same dependency dll file name. 但是,我不确定如何执行此操作,因为它们的应用程序以及我们的dll都将查找相同的依赖项dll文件名。 Can anyone tell me what the best/cleanest way to deal with this problem is? 谁能告诉我解决这个问题的最好/最干净的方法是什么?
Thanks! 谢谢!
You could solve this kind of problem using a (new) additional DLL you would deliver and that would take care of handling the versions conflict (at runtime) - being a kind of proxy between your app and its dependencies. 您可以使用将提供的(新)附加DLL解决这类问题,并负责处理(在运行时)版本冲突-作为应用程序及其依赖项之间的一种代理。
An alternative would be to use the Windows Forwarded Libraries mechanism . 一种替代方法是使用Windows 转发的库机制 。
Forwarders are a handy way to accommodate functionality moving from one DLL to another 转发器是容纳从一个DLL到另一个DLL的功能的便捷方法
You can use several ways to declare forwarders, such as a module definition ( .def
) file and a #pragma
: 您可以使用多种方式声明转发器,例如模块定义( .def
)文件和#pragma
:
#pragma comment(linker, "/export:function=otherdll.function")
Generally speaking, it won't work. 一般来说,它不会起作用。 This is due to the fact that the third party DLL versions might interfere with each other when loaded into memory. 这是由于以下事实:第三方DLL版本在加载到内存时可能会相互干扰。 One example could be if there is an exclusive resource like eg a file in a specific directory. 一个示例可以是,如果在特定目录中存在诸如文件之类的专有资源。 Or a specific device. 或特定的设备。 The problem is, nobody knows probably not even the manufacturer of the 3rd party DLLs - so extensive testing is necessary. 问题是,没有人甚至可能都不知道第三方DLL的制造商-因此必须进行广泛的测试。
But maybe you're lucky and it works anyway. 但是也许您很幸运,它仍然可以工作。 My recipe: 我的食谱:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.