更新 C++ 的 DLL Visual Studio 中的项目
我有一个项目使用我创建的 DLL。一切都运行得很好,但我现在正在扩展 DLL 中的库来优化一些旧函数。
我想知道的是,如果我只是将库修改为仅主函数体发生变化而没有其他任何内容,我可以重建DLL并将其替换为旧的DLL,还是因为函数体发生了变化,我需要重建任何项目使用了这个DLL。
我问的主要原因是因为所有这些项目都让我引用 .lib 文件,老实说我不确定 DLL 项目的 .lib 文件中到底是什么。
任何建议将不胜感激。
谢谢
I have a project that uses a DLL that I have created. Everything works wonderfully, but I am now extending the library in the DLL to optimize some older functions.
What I was wondering is if I just modify the library to where only the main function body changes and nothing else can I just rebuild the DLL and replace it with the old one or is it because the function body changed I need to rebuild any projects that used this DLL.
The main reason I asked is because all of these projects have me referencing the .lib file and to be honest I am not sure what is exactly in a .lib file of a DLL project.
Any advice would be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只是更改函数来优化它们,而不更改函数签名,那么您只需构建库并部署它(替换旧库)。
但是,如果您需要更改函数签名,那么您可以执行(至少)两件事之一:
您可以在此处阅读有关 .lib/.dll 的更多信息: http://www.screenio.com/tips /dll.htm
If you're just changing the functions to optimize them, without changing the function signatures, then you can just build your library and deploy it (replacing the old library).
However, if you need to change the function signatures then you can do one of (at least) two things:
You can read more about .lib/.dll here: http://www.screenio.com/tips/dll.htm
如果您只更改函数体,并且这些函数不是模板函数,并且使用相同的编译选项编译 dll,就像当时那样,那么应该没问题。
您可能必须注意 dll 和可执行文件使用相同版本的 Microsoft C++ 运行时库。将加载的它的版本可以被清单文件覆盖。
If you only change function bodies, and those functions are not template functions, and you compile the dll with the same compile options, as you did back then, you should be fine.
You might have to take care that both the dll and your executable use the same version of the Microsoft C++ Runtime Library. The version of it, that will be loaded, can be overriden by manifest files.
.lib 文件允许您编写使用 DLL 的代码,就像它是静态库一样。本质上它包含 DLL 中所有函数的声明。它是在您构建 DLL 时生成的,但如果您不添加(或删除,但一旦部署就永远不应该删除)函数,或更改函数的签名,那么它就不会更改。您还将有一个头文件来告诉编译器您的 DLL 中有哪些函数,并且当您添加函数或更改函数的签名时,您将手动更改该头文件。
如果您唯一的更改是对函数内的实际代码进行错误修复(或性能改进或其他),那么您可以只部署更新的 DLL。对于其他更改,您必须部署库和 DLL。如果您更改了函数的签名,则必须部署新的 .h,将调用代码更改为使用修改后的参数进行调用,然后重新编译调用代码。如果您刚刚添加了一些内容,则无需重建调用代码。
The .lib file lets you write code that uses your DLL as though it was a static library. Essentially it contains the declarations of all the functions in your DLL. It is generated whenever you build the DLL, but if you don't add (or remove, but you should never remove once you've deployed) a function, or change the signature of a function, then it won't change. You will also have a header file to tell the compiler what functions are in your DLL and this you will change by hand when you add a function or change the signature of a function.
If your only change is a bugfix (or perf improvement or whatever) to the actual code inside a function, you can get away with deploying only the updated DLL. For other changes you must deploy the lib and the DLL. If you've changed the signature of a function you'll have to deploy the new .h, change the calling code to call with the revised parameters, and then get the calling code recompiled. If you just added something you can get away with not rebuilding the calling code.