缺少第三方dll,等待期间该怎么办?
我正在开发一个遗留的 C++ 项目,并且缺少第三方 dll。 我被告知该 dll 将在两周内可用。 我需要执行的工作是纯UI。 我真的不需要这个dll。 但是,如果没有 dll,应用程序将无法运行。 我应该注释掉所有调用 dll 的地方还是创建一个占位符 dll,无论哪种方式都有大量的 API 需要覆盖? 难道没有人有更好的主意吗?
I am working on a legacy C++ project and missing a third party dll. I was told that the dll will be available in two weeks. The work that I need to perform is pure UI. I don't really need the dll. However, the application won't run without the dll. Should I comment out all the places that the dll get called or create a place holder dll, either way there are tons of APIs to cover? Doesn't anybody have a better idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你不会走得太远。 面对如此多的调用,编写包装器是一种浪费时间的行为,除非您进了监狱或其他什么地方。
您无法从正在运行的安装中获取 DLL 的副本吗? 或者这是一个许可问题?
You won't get far. With that many calls, writing a wrapper is a bad use of time unless you're in prison or something.
You can't take a copy of the DLL from a running installation? Or is this a licensing problem?
对于我来说,尽管存在许可和其他问题,我还是会尝试在此处复制 .DLL。 除此之外,我认为找到另一个项目......
Me, I'd attempt to duplicate the .DLL here licensing and other issues notwithstanding. Other than that find another project I think...
如果您可以访问 EXE 的源代码(看起来是这样),并且您正在运行任何最新的 Visual Studio(6 或更高版本),则一个简单的解决方案是使用 /DelayLoad 进行重建。 这意味着链接器将设置 EXE 来调用 LoadLibrary 并在第一次调用时解析导入。 这意味着,如果您实际上没有调用 DLL,则它永远不会加载,并且通过扩展,也不会丢失。
这意味着您不必创建任何存根 DLL; 这是5分钟的改变。
If you have access to the source code of the EXE (it seems so), and you're running any recent Visual Studio (6 or later), an easy solution is to rebuild with /DelayLoad. This means the linker will set up the EXE to call LoadLibrary and resolve imports at the first call. This means that if you don't actually call the DLL, it's never loaded, and by extension, not missing.
This means you do not have to create any stub DLL; it's a 5 minute change.
编写单元测试。 否则的话,听起来两周的时间是理所应当的。
Write unit tests. Otherwise, sounds like two weeks of thumb twiddling is in order.
我通常通过
LoadLibrary
和GetProcAddress
调用动态加载非必要的 DLL,这样我的应用程序就可以在没有它们的情况下运行。 应用程序可以检查 DLL 是否已加载,如果没有加载,则它不提供 DLL 提供的功能。 我已经将其与拼写检查器、条形码库等一起使用。可能需要考虑。I usually dynamically load non-essential DLLs via
LoadLibrary
andGetProcAddress
calls so my applications can run without them. The application can check if the DLL was loaded, and if not, it doesn't offer the functionality the DLL provides. I have used this with spell checkers, barcode libraries, etc. Might be something to consider.我会创建一个不执行任何操作(或者只要您需要它执行的操作)的存根 DLL。 然后当你拿到真正的那张时,把它放在你的存根上就完成了。
如果您需要创建无数个函数,您也许可以使用 perl 或其他脚本语言来帮助将大量链接器错误转换为包含所需函数原型的文件。
I'd create a stub DLL that does nothing (or as little as you need it to do). Then when you get the real one, drop it on top of your stub and you're done.
If there are a zillion functions you need to create, you might be able to use perl or some other scripting language to help turn your slew of linker errors into a file containing prototypes of the functions you need.