1

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?

Peter Mitrano
  • 2,132
  • 28
  • 31

2 Answers2

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.

Peter Mitrano
  • 2,132
  • 28
  • 31
-1

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.

dewaffled
  • 2,850
  • 2
  • 17
  • 30
  • 1
    Does this answer the question? I'm not asking how to include a library. I'm asking how to introspect dependencies. – Peter Mitrano Jun 29 '15 at 22:14
  • That's how this message is generated by boost. i.e. library authors manually added pragma with library name to headers. Without it you would get usual unresolved external symbol errors. – dewaffled Jun 29 '15 at 22:15
  • 1
    Ok, I see how it is relevant. I could search the boost source for such a comment. I don't think it answers the question though. I want to know which of my dependencies is causing that boost library to be needed. – Peter Mitrano Jun 29 '15 at 22:18