Hi, 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.
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
All my header files are guarded with the standard #ifndef [Header] #define [Header] ... #endif.
[Modulator.h]
prototypes for Modulator class
[ChorusUnit.h] ->Modulator.h
prototypes for Chorus classes which have member objects of type Modulator
[AudioHandler.h] ->ChorusUnit.h
prototypes for AudioHandler class which has member objects of Chorus classes
[Chorus.cpp] ->AudioHandler.h
definitions for the members of Modulator and Chorus classes
[AudioHandler.cpp] ->Chorus.cpp
definitions for the members of AudioHandler class
[ChorusUnit.cpp] ->AudioHandler.cpp
the file containing the main() function that actually runs the code of my project.
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.
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.
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!