VS2010:静态链接单个库

发布于 2024-12-22 01:40:19 字数 241 浏览 1 评论 0原文

情况:

我正在使用 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 技术交流群。

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

发布评论

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

评论(1

智商已欠费 2024-12-29 01:40:19

在这里回答我自己的问题:

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

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