I've been trying to make something where I can just plug-in a new implementation (for things like opening a window, displaying graphics, etc.) and it work just like before. I've added a couple of other things like a resource manager, but now I'm getting linker errors. This didn't happen until I tried to do what the IDE calls 'Clean All Targets' (which I think is a complete rebuild?).
Currently, it gives me several ' "..." referenced from: ...' errors, which to me looks like it's complaining about no definition of the constructor, destructor, and a function called 'SetFilename' (Which are defined in the .cpp file). All of the classes it complains about are templated from one called 'Resource'.
At the end is 'Symbol(s) not found' and 'collect2: ld returned 1 exit status'.
I thought it should compile just fine (Whether it works or not, who knows! :P), but that obviously isn't working out too well...
The header of the class that is giving the problems:
#ifndef BGE_RESOURCE_H
#define BGE_RESOURCE_H
#include <string>
namespace bge
{
template < class T >
class Resource
{
public:
Resource();
Resource( const std::string& name );
~Resource();
void SetFilename( const std::string& name );
const std::string& GetFilename() const;
bool Load();
void Unload();
bool IsLoaded() const;
const T* const GetResource();
void ReturnResource();
private:
T* resource;
unsigned int usedAmount;
bool loaded;
std::string filename;
};
class IFont;
class IImage;
class IMusic;
class ISound;
typedef Resource< IFont > FontResource;
typedef Resource< IImage > ImageResource;
typedef Resource< IMusic > MusicResource;
typedef Resource< ISound > SoundResource;
}
#endif // BGE_RESOURCE_H
I have no idea how to fix this... Any ideas?