VS2010: Link in a single library statically

断了今生、忘了曾经 提交于 2019-12-30 06:01:52

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8581247/vs2010-link-in-a-single-library-statically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!