构建没有依赖关系的库
我这里有一个名为 HugeApp 的巨大应用程序,它需要不同的库(我已编码),其中一些库可能需要依赖项(来自互联网的其他库或此处开发的临时库) )。
我想知道从 HugeApp
隐藏一些这些依赖项是否可行和/或一个好主意。
假设您创建一个库负责在系统上进行加密通信,顶级应用程序是否关心和/或需要知道系统的这部分(通信)需要一些加密库?它可能是特定于实现的......或者不是......
谢谢
I've got a huge application here called HugeApp
, it needs different libraries (which I've coded) and some of these libraries might need dependencies (other libs coming from the internet or ad hoc lib developped here).
I was wondering, if it was feasible and/or a good idea to hide some of these dependencies from HugeApp
.
Let's say that you make a library in charge of doing the encrypted communication on a system, does the top application care and/or needs to know that there is some encryption libraries that are needed for this part (comms) of the system? It might be implementation specific... or not...
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不需要知道,如果您将这些库构建为外部 DLL,那么外部库是唯一关心依赖关系的东西。如果您添加对预构建 DLL 的引用,那么 HugeApp 不需要了解库的依赖关系(只要它们存在于库中或者存在适当的 DLL 或 lib 文件,以便您的 dll 可以充分利用它)。如果有的话,您的库可以完全是另一个项目,并且您可以包含对此的引用,在这种情况下,您的 HugeApp 的项目只关心该主要引用,而另一个项目将处理其他所有内容。
There's no need for it to know, if you build those libraries as external DLL's then the external libraries are the only thing that care about the dependency. If you add a reference to the pre-built DLL then HugeApp doesn't need to know about the dependencies of the library (as long as they are either present in the library or the appropriate DLL or lib file is present so that your dll can make use of it). If anything your library can be another project altogether and you can include a reference to that in which case the project of your HugeApp only cares about that main reference and the other project will handle everything else.
如果在链接器优化中启用 /OPT:REF,您将列出哪些(如果有)库在链接期间没有项目使用的函数或数据。然后,您可以从项目设置中的依赖项列表和链接行中删除它们。如果 VS 解决方案中存在/使用了另一个静态库的依赖项,这将减少删除该静态库的机会。
If you enable /OPT:REF in linker optimizations it you will list which (if any) libraries that have no functions or data used by the project during link time. You can then remove them from the dependency list and link line in project settings. This will reduce the chance of removing a static library that is a dependency of another static library if any are present/used in your VS solution.