MSVC 12 Show where a library is being required

2019-07-30 10:01发布

问题:

TL;DR Is there a flag or something that will tell msvc to print out which library/object file requires a given library?

say I get an error message like:

LNK1104 fail to open file: boost_thread-vc120-mt-gd-1_56.lib

I expect this because I haven't told msvc where to find that. But, let's say I want to know why do I need that?.

In other words, let's say I'm linking against foo.lib bar.lib and I've got a bunch of code in my project. Will msvc show me whether it's foo.lib, bar.lib, or my own code that needs it?

回答1:

adding /VERBOSE:REF shows which object files reference which symbols in which libraries, all in a nice indented fashion. This is what I was looking for.



回答2:

In Visual C++ additional libraries can be specified with #pragma comment(lib, "libname.lib") instruction in source code. It may be placed in library headers and is applied when header is included in application sources.



标签: c++ msvc12