title: Visual Studio 2010's strange "warning LNK4042"
body: <p>I've just been beaten (rather hardly) on the head by some non-trivial warning from Visual Studio 2010 (C++).</p>
  
  <p>The compilation gave the following output:</p>
  
  <blockquote>
    <p>1 Debug\is.obj : warning LNK4042: object specified more than once; extras ignored<br>
    1 Debug\make.obj : warning LNK4042: object specified more than once; extras ignored<br>
    1 Debug\view.obj : warning LNK4042: object specified more than once; extras ignored<br>
    1 identity.obj : error LNK2019: unresolved external symbol <code>void __cdecl
    test::identity::view(void)</code> (?view@identity@test@@YAXXZ) referenced in function <code>void __cdecl test::identity::identity(void)</code> (?identity@0test@@YAXXZ)<br>
    1 identity.obj : error LNK2019: unresolved external symbol <code>void __cdecl test::identity::make(void)</code> (?make@identity@test@@YAXXZ) referenced in function <code>void __cdecl test::identity::identity(void)</code> (?identity@0test@@YAXXZ)<br>
    1 range.obj : error LNK2019: unresolved external symbol <code>void __cdecl test::range::is(void)</code> (?is@range@test@@YAXXZ) referenced in function <code>void __cdecl test::range::range(void)</code> (?range@0test@@YAXXZ)  </p>
  </blockquote>
  
  <p>Linker errors are always a pain to debug... but there were unresolved references, and so I checked... but the source is well-formed... and finally it hit me:</p>
  
  <p>My folder hierarchy looks like so:</p>
  
  <pre><code>src/
    identity/
      is.cpp
      make.cpp
      view.cpp
    range/
      is.cpp
      make.cpp
      view.cpp
  </code></pre>
  
  <p>and so does the hierarchy in the Solution (I always set it up so that it mimicks the "real" folder structure).</p>
  
  <p>And the diagnostic outputs:</p>
  
  <pre><code>Debug\is.obj
  Debug\make.obj
  Debug\view.obj
  </code></pre>
  
  <p>Along with a warning which says that the <code>.obj</code> has been passed twice to the linker and that one will be ignored.</p>
  
  <p>Search no more: Visual has neatly flatten my folder hierarchy, and therefore is unable to neatly compile the source.</p>
  
  <p>At the moment, I am simply thinking of renaming the files, that should cover the issue...</p>
  
  <p>... but is there a way to have Visual Studio NOT flatten the file hierarchy ?</p>