VS2010:静态链接单个库
情况:
我正在使用 VS2010 构建一个库,它依赖于 LibraryA。我只使用 LibraryA 提供的众多功能之一,因此我想静态链接它。
我读到的有关此内容的所有内容都告诉我将整个项目设置为针对 MFC 静态链接,这是我不想做的事情。我对我的库动态链接 Windows DLL 很满意;我只想静态链接到 LibraryA。
闲逛选项窗口,我似乎没有看到这样的选项。真的是全有或全无吗?
谢谢, -本
Situation:
I'm building a library with VS2010, and it has a dependency on LibraryA. I am only using one of many features that LibraryA offers, so I want to link it in statically.
Everything I'm reading about this tells me to set the whole project to link statically against MFC, which is something I don't want to do. I'm just fine with my library dynamically linking against windows DLLs; I just want to statically link against LibraryA only.
Fooling around with the options windows, I don't seem to see such an option. Is it really all or nothing?
Thanks,
-Ben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里回答我自己的问题:
在 VS 中静态链接库所需要做的就是:
1) 将 .lib 文件添加到属性 -> 中找到的列表中。链接器->输入:附加依赖项。
2)在属性中添加.lib文件所在目录->链接器->一般:附加库目录。
如果 .lib 文件是静态链接库,那么这就是您所要做的。
我感到困惑的主要原因是 .lib 文件也可能是 dll 旁边的伴随文件,而不是静态库本身。
Answering my own question here:
All you need to do to statically link a library in VS is:
1) Add the .lib file to the list found in properties -> linker -> input : Additional Dependencies.
2) Add the directory that the .lib file is located at to the properties -> linker -> general : Additional Library Directories.
If the .lib file is a statically linked library, then that is all you have to do.
The main reason I was confused was that a .lib file could also be a companion file alongside a dll, and not a static library itself.