title: Complicated error LNK2005: already defined C++
body: <p>I'm getting the LNK2005: already defined in (...) error when building my project in Visual Studio 2008. I've referenced other related questions, but mine seems to be a bit more complicated due if nothing else to the number of files I'm working with.</p>
  
  <p>First, I think it will be helpful for me to map out the #include statements I have in the files of my project in the format [current_file] ->includes_this_file</p>
  
  <p>All my header files are guarded with the standard #ifndef [Header] #define [Header] ... #endif.</p>
  
  <p>[Modulator.h]</p>
  
  <p>prototypes for Modulator class</p>
  
  <p>[ChorusUnit.h] ->Modulator.h</p>
  
  <p>prototypes for Chorus classes which have member objects of type Modulator</p>
  
  <p>[AudioHandler.h] ->ChorusUnit.h</p>
  
  <p>prototypes for AudioHandler class which has member objects of Chorus classes</p>
  
  <p>[Chorus.cpp] ->AudioHandler.h</p>
  
  <p>definitions for the members of Modulator and Chorus classes</p>
  
  <p>[AudioHandler.cpp] ->Chorus.cpp</p>
  
  <p>definitions for the members of AudioHandler class</p>
  
  <p>[ChorusUnit.cpp] ->AudioHandler.cpp</p>
  
  <p>the file containing the main() function that actually runs the code of my project.</p>
  
  <p>The ordering of includes is because all the definitions of functions to the classes found in Modulator.h, ChorusUnit.h, and AudioHandler.h need to reference members of the other classes, so I needed the prototypes defined first for all the classes to see each other.</p>
  
  <p>The error specifically says that every single definition found in Chorus.cpp and AudioHandler.cpp in file Chorus.obj is already defined in AudioHandler.obj.
  Also there is another set of the same error type that says every single definition found in Chorus.cpp and AudioHandler.cpp in file ChorusUnit.obj is already defined in AudioHandler.obj.</p>
  
  <p>There is probably a pretty straightforward solution, but I am not particularly experience (being mostly a Java programmer) in linking in general. As far as my limited knowledge on the subject goes, I only defined everything once and everything was only included once so I'm personally at a loss as to why these are already defined. Some please enlighten me!</p>