更新 C++ 的 DLL Visual Studio 中的项目

发布于 2024-12-10 03:42:07 字数 253 浏览 0 评论 0原文

我有一个项目使用我创建的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

铁轨上的流浪者 2024-12-17 03:42:07

如果您只是更改函数来优化它们,而不更改函数签名,那么您只需构建库并部署它(替换旧库)。

但是,如果您需要更改函数签名,那么您可以执行(至少)两件事之一:

  1. 修改使用您的库的代码以使用新的函数签名。
  2. 如果#1 不是一个选项,那么请考虑保留旧函数并弃用它。使用最新版本的应用程序必须避免使用已弃用的方法。

您可以在此处阅读有关 .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:

  1. Modify the code that's using your library to use the new function signatures.
  2. If #1 is not an option, then consider leaving the old function and deprecating it. Applications with make use of your latest version will have to avoid using the deprecated methods.

You can read more about .lib/.dll here: http://www.screenio.com/tips/dll.htm

指尖上的星空 2024-12-17 03:42:07

如果您只更改函数体,并且这些函数不是模板函数,并且使用相同的编译选项编译 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.

青春如此纠结 2024-12-17 03:42:07

.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文