multiple definitions question
<p>This question is as a result of <a href="http://stackoverflow.com/questions/3495422/undefined-reference-question">http://stackoverflow.com/questions/3495422/undefined-reference-question</a>.</p>

<p>When I try compiling this:</p>

<pre><code>#include "OriAudioCache.hpp"

    int main()
    {
        System *audioSystem(0);
        FMOD_RESULT result;
        result = System_Create(&amp;audioSystem);
        FMOD_CHECK_STATE(result);
        OriAudioCache cache(audioSystem, 20);
        string title("Ambitious Girl");
        string path("/home/findrzkeeprz/Desktop/Resources/The_Ambitious_Girl.mp3");
        cache.LoadSound(title, path, Default);
        vector&lt;OriSound&gt;::iterator v_iter(cache.FindSound(title));
        cache.PlaySound(v_iter-&gt;sound());
    }
</code></pre>

<p>which uses these files (directly or indirectly):
OriAudioCache.hpp</p>

<pre><code>#ifndef ORI_AUDIO_CACHE_HPP_
#define ORI_AUDIO_CACHE_HPP_

#include "OriSound.hpp"
#include "OriChannel.hpp"

class OriAudioCache
{
    public:
         OriAudioCache(System *audioSystem, int maxChannels);

        ~OriAudioCache()
        {
            vector&lt;OriSound&gt;::iterator v_iter(audioCache_.begin());
            for(; v_iter != audioCache_.end(); ++v_iter)
            {
                v_iter-&gt;~OriSound();
            }
                delete audioSystem_;
        }

        void LoadSound(string const&amp; title, string const&amp; path, AudioLoadMode mode);
        vector&lt;OriSound&gt;::iterator FindSound(string const&amp; title);
        void RemoveSound(string const&amp; title);
        void PlaySound(Sound* sound);
        vector&lt;OriChannel&gt;::iterator RequestChannel(bool &amp;allocStatus, FMOD_CHANNELINDEX &amp;allocMode);
        void ReleaseChannel(Channel *channel);

    private:
        void inline SortChannels() {sort(channels_.begin(),channels_.end());}

        vector&lt;OriSound&gt; audioCache_;
        vector&lt;OriChannel&gt; channels_;
        System *audioSystem_;
};

#endif
</code></pre>

<p>OriAudioCache.cpp</p>

<pre><code>#include "OriAudioCache.hpp"

OriAudioCache::OriAudioCache(System *audioSystem, int maxChannels)
        :audioSystem_(audioSystem), channels_(maxChannels){}

void OriAudioCache::LoadSound(string const&amp; title, string const&amp; path, AudioLoadMode mode)
{
    OriSound sound(title, path, audioSystem_, mode);
    vector&lt;OriSound&gt;::iterator pos =lower_bound(audioCache_.begin(), audioCache_.end(), sound);
    audioCache_.insert(pos, sound);
}

vector&lt;OriSound&gt;::iterator OriAudioCache::FindSound(string const&amp; title)
{
    vector&lt;OriSound&gt;::iterator v_iter(audioCache_.begin());
    for(; v_iter != audioCache_.end(); ++v_iter) //Would better if I could use a binary search here
    {
        if(v_iter-&gt;title() == title) return v_iter;
        else continue;
    }
    return audioCache_.end(); 
}
void OriAudioCache::RemoveSound(string const&amp; title)
{
    vector&lt;OriSound&gt;::iterator v_iter(audioCache_.begin());
    for(; v_iter != audioCache_.end(); ++v_iter) //Would better if I could use a binary search here
    {
        if(v_iter-&gt;title() == title) audioCache_.erase(v_iter);
        else continue;
    }
}

void OriAudioCache::PlaySound(Sound* sound)
{
    bool channelAlloc(false);
    FMOD_CHANNELINDEX allocMode = FMOD_CHANNEL_FREE;
    vector&lt;OriChannel&gt;::iterator oriChannel = RequestChannel(channelAlloc, allocMode);
    if(channelAlloc)
    {
        FMOD_RESULT result;
        Channel *chnl = oriChannel-&gt;channel();
        result = audioSystem_-&gt;playSound(allocMode, sound, false, &amp;chnl);
        FMOD_CHECK_STATE(result);
        bool isPlaying(false);
        chnl-&gt;isPlaying(&amp;isPlaying);

        while(isPlaying)
        {
            chnl-&gt;isPlaying(&amp;isPlaying);
        }

        bool paused(false);
        chnl-&gt;getPaused(&amp;paused);
        if(!paused)
        {
            ReleaseChannel(chnl);
        }
        SortChannels(); //sort channels, reoder for channel requests
    }
}

vector&lt;OriChannel&gt;::iterator OriAudioCache::RequestChannel(bool &amp;allocStatus, FMOD_CHANNELINDEX &amp;allocMode)
{
    vector&lt;OriChannel&gt;::iterator vOri_iter(channels_.begin());
    if(vOri_iter-&gt;status() == false)
    {
        if(vOri_iter-&gt;channel() == 0) 
        {
            allocMode = FMOD_CHANNEL_FREE;
            vOri_iter-&gt;setStatus(true); // flag channel as being used
            return vOri_iter;
        }
        else allocMode = FMOD_CHANNEL_REUSE;
        vOri_iter-&gt;setStatus(true); // flag channel as being used
        return vOri_iter;
    }
    else return channels_.end();
}

void OriAudioCache::ReleaseChannel(Channel *channel)
{
    bool playing(false);
    bool paused(false);
    channel-&gt;isPlaying(&amp;playing);
    channel-&gt;getPaused(&amp;paused);
    if(!playing &amp;&amp; !paused)
    {
        vector&lt;OriChannel&gt;::iterator vOri_iter(channels_.begin());
        for(; vOri_iter != channels_.end(); ++vOri_iter)
        {
            if(vOri_iter-&gt;channel() == channel) vOri_iter-&gt;setStatus(false);
        }
    }
}
</code></pre>

<p>OriSound.hpp</p>

<pre><code>#ifndef ORI_SOUND_HPP_
#define ORI_SOUND_HPP_

#include "Public/ThirdParty.hpp"
#include "Public/Public.hpp"

class OriSound
{
    public:
        OriSound()
            :title_(), path_(), sound_(0)
        {}

        OriSound(string const&amp; title, string const&amp; path, System* const&amp; audioSystem, AudioLoadMode mode)
            : title_(title), path_(path)
        {
            FMOD_RESULT result;
            audioSystem-&gt;createSound(path.c_str(), mode, 0, &amp;sound_);
            FMOD_CHECK_STATE(result);
        }

        ~OriSound()
        {
            delete sound_;
        }

        string title() const { return title_;}
        string path() const {return path_;}
        Sound *sound() const {return sound_;}

    private:
        string title_;
        string path_;
        Sound *sound_;
};

bool operator&lt;(OriSound const&amp; lhs, OriSound const&amp; rhs)
{
    int result = (lhs.title()).compare(rhs.title());
    if(result == 0) return false;
    else if(result &lt; 0 ) return true;
    else return false;
}
#endif
</code></pre>

<p>OriChannel.hpp</p>

<pre><code>#ifndef ORI_CHANNEL_HPP_
#define ORI_CHANNEL_HPP_

#include "Public/Public.hpp"

class OriChannel
{
    public:
        OriChannel()
            :status_(false), channel_(0)
        {}

        bool status() const {return status_;}
        Channel* channel() const {return channel_;}
        void setStatus(bool value) { status_ = value;}

    private:
        bool status_;
        Channel *channel_;
};

bool operator&lt;(OriChannel const&amp; lhs, OriChannel const&amp; rhs)
{
    return lhs.status() &lt; rhs.status();
}


#endif
</code></pre>

<p>Public.hpp</p>

<pre><code>#ifndef PUBLIC_HPP_
#define PUBLIC_HPP_

#include &lt;algorithm&gt;
#include &lt;iostream&gt;
#include &lt;istream&gt;
#include &lt;ostream&gt;
#include &lt;vector&gt;

using namespace std;

#endif
</code></pre>

<p>ThirdParty.hpp</p>

<pre><code>#ifndef THIRD_PARTY_HPP_
#define THIRD_PARTY_HPP_

#include "FMODEX/fmod_errors.h"
#include "FMODEX/fmod.hpp"

#include "Public/Public.hpp"

using namespace FMOD;

void FMOD_CHECK_STATE(FMOD_RESULT result)
{
    if (result != FMOD_OK)
    {
        cout &lt;&lt; "FMOD error! (" &lt;&lt; result &lt;&lt; ")" &lt;&lt; FMOD_ErrorString(result) &lt;&lt; endl;
        exit(-1);
    }
}

typedef enum
{
    Default = FMOD_DEFAULT,
    Hardware_2D_CreateStream = FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM ,
    Hardware_2D_CreateSample = FMOD_HARDWARE | FMOD_2D | FMOD_CREATESAMPLE,
    Hardware_3D_CreateStream = FMOD_HARDWARE | FMOD_3D | FMOD_CREATESTREAM ,
    Hardware_3D_CreateSample = FMOD_HARDWARE | FMOD_3D | FMOD_CREATESAMPLE,
    Software_2D = FMOD_SOFTWARE | FMOD_2D,
    Software_2D_CreateStream = FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM ,
    Software_2D_CreateSample = FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESAMPLE,
    Software_2D_CreateCompressedSample = FMOD_SOFTWARE | FMOD_2D | FMOD_CREATECOMPRESSEDSAMPLE,
    Software_3D_CreateStream = FMOD_SOFTWARE | FMOD_3D | FMOD_CREATESTREAM ,
    Software_3D_CreateSample = FMOD_HARDWARE | FMOD_3D | FMOD_CREATESAMPLE,
    Software_3D_CreateCompressedSample = FMOD_SOFTWARE | FMOD_3D | FMOD_CREATECOMPRESSEDSAMPLE
}AudioLoadMode;
#endif
</code></pre>

<p>I get multiple definition errors:</p>

<pre><code>findrzkeeprz@Aardvak:~/Documents/Chidori/Engine/Audio$ make
g++ -ggdb -I../../ -I../../Engine -I../../Include -I../../Public -o audio OriAudioCache.cpp main.cpp ../../Libraries/FMODEX/libfmodex.so
/tmp/ccWiUARs.o: In function `FMOD_CHECK_STATE(FMOD_RESULT)':
/home/findrzkeeprz/Documents/Chidori/Engine/Audio/../../Public/ThirdParty.hpp:12: multiple definition of `FMOD_CHECK_STATE(FMOD_RESULT)'
/tmp/ccF7Dod3.o:/home/findrzkeeprz/Documents/Chidori/Engine/Audio/../../Public/ThirdParty.hpp:12: first defined here
/tmp/ccWiUARs.o: In function `operator&lt;(OriSound const&amp;, OriSound const&amp;)':
/home/findrzkeeprz/Documents/Chidori/Engine/Audio/OriSound.hpp:38: multiple definition of `operator&lt;(OriSound const&amp;, OriSound const&amp;)'
/tmp/ccF7Dod3.o:/home/findrzkeeprz/Documents/Chidori/Engine/Audio/OriSound.hpp:38: first defined here
/tmp/ccWiUARs.o: In function `operator&lt;(OriChannel const&amp;, OriChannel const&amp;)':
/home/findrzkeeprz/Documents/Chidori/Engine/Audio/OriChannel.hpp:23: multiple definition of `operator&lt;(OriChannel const&amp;, OriChannel const&amp;)'
/tmp/ccF7Dod3.o:/home/findrzkeeprz/Documents/Chidori/Engine/Audio/OriChannel.hpp:23: first defined here
collect2: ld returned 1 exit status
make: *** [audio] Error 1
</code></pre>

<p>What I'm I doing wrong here?</p>
