构建静态库(.lib)VS 2010 Pro
我有一个关于在 VS 2010 Pro 中构建静态库的新手问题。
当您选择构建静态库 (.lib) 而不是应用程序时,项目属性中的链接器选项将消失。通常我会转到“链接器”->“输入”->“附加依赖项”来添加项目所需的 .lib 文件。
我已经构建了该库并将其添加到我的主应用程序项目中的“链接器”->“输入”->“附加依赖项”下。现在,当我去构建主应用程序(项目 .lib 文件中包含上述静态库)时,我收到有关库中使用的方法的链接器错误。
构建静态库时在哪里添加所需的.lib文件?
I have a newbie question about building a static library in VS 2010 Pro.
When you choose to build a static library (.lib) instead of an application, the Linker option in project properties disappears. Normally I go to Linker->Input->Additional Dependencies to add the needed .lib files for a project.
I've built the library and added it to my main application project under Linker->Input->Additional Dependencies. Now when I go to build my main application (with the above static library included in the project .lib files), I am getting a linker error about a method used in the library.
Where do I add the required .lib files when building the static library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
静态库与您的可执行文件链接。静态库具有的任何依赖项(它需要的外部库)也必须在可执行文件中指定。
因此,如果
libA
需要libB
,那么与libA
链接的应用程序也必须与libB
链接。A Static library is linked with your executable. Any dependencies that your static library has (external libraries it requires) must also be specified in your executable.
So, if
libA
requireslibB
, then an application that links withlibA
will also have to link withlibB
.最简单的方法是将依赖的 .lib 添加到主应用程序的链接器页面中。
The easiest way is to add the dependent .lib to your main application in its linker page.
如果库 A 始终依赖于库 B,那么您可以强制在库 A 的源文件之一中发生这种情况。例如:
If library A always depends on library B, then you can force that to happen in one of the source files in library A. For example: