title: C++. Error LNK1104. Cannot open library file for the first time solution is built
body: <p>I have legacy MSVS solution with C++ projects. When I take it from Version Control System and try to build it for the very first time (when it's clean) - I get error: LNK 1104 library can't be found. </p>
  
  <p>When I try to build it for the second time - everything is built ok. </p>
  
  <p>Project "A" (C++) depends on library (lib file) that is Project "B" (also C++).</p>
  
  <p>"A" has code like that in one of it's cpp files (may be stdafx.h is the better place for #pragma comments?):</p>
  
  <pre><code>#pragma comment(lib, "B.lib")
  </code></pre>
  
  <p>that causes Linker error for the very first built</p>
  
  <p>I investigated the first built results: "B" project is successfully compiled, "lib" file is produced, and "A" project (that depends on "B") is the last project in solutions projects build order. </p>
  
  <p>I wonder why "A" doesn't see "B" library for the very first time as "B" should be built earlier than "A". When I build the same solution for the second time - no linker errors. </p>