VS2010:静态链接单个库 [英] VS2010: Link in a single library statically

查看:21
本文介绍了VS2010:静态链接单个库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:

我正在用 VS2010 构建一个库,它依赖于 LibraryA.我只使用 LibraryA 提供的众多功能之一,所以我想静态链接它.

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.

我正在阅读的关于此的所有内容都告诉我将整个项目设置为与 MFC 静态链接,这是我不想做的事情.我的库动态链接到 Windows DLL 就好了;我只想静态链接到 LibraryA.

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?

谢谢,-本

推荐答案

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

Answering my own question here:

在 VS 中静态链接库所需要做的就是:

All you need to do to statically link a library in VS is:

1) 将 .lib 文件添加到属性 -> 链接器 -> 输入:附加依赖项中的列表中.

1) Add the .lib file to the list found in properties -> linker -> input : Additional Dependencies.

2) 将 .lib 文件所在的目录添加到属性 -> 链接器 -> 常规:附加库目录.

2) Add the directory that the .lib file is located at to the properties -> linker -> general : Additional Library Directories.

如果 .lib 文件是静态链接库,那么您只需要做这些.

If the .lib file is a statically linked library, then that is all you have to do.

我感到困惑的主要原因是 .lib 文件也可以是 dll 的伴随文件,而不是静态库本身.

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.

这篇关于VS2010:静态链接单个库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆