0

I'm making a little breakout test game with SDL and C++ but I run into the following build error:

Undefined symbols for architecture x86_64:
"ResourceManager::PlayAudio(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool)", referenced from:
  Breakout::run() in Breakout.o
"Audio::Audio()", referenced from:
  ResourceManager::AddAudio(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in ResourceManager.o
ld: symbol(s) not found for architecture x86_64

Here is what I have in my ResourceManager.h:

class ResourceManager {
static map<string, Texture*> Textures;
static map<string, Audio*> Audios;

static ResourceManager instance;

SDL_Renderer* CurrentRenderer;


public:
static ResourceManager* GetInstance();

void SetRenderer(SDL_Renderer* renderer);
void AddTexture(string TextureName, string file);
void RenderTexture(string TextureName, int x, int y);
void AddAudio(string AudioName, string file);
void PlayAudio(string AudioName, bool Loop);
};

And here is my ResourceManager.cpp:

map<string, Texture*> ResourceManager::Textures;
map<string, Audio*> ResourceManager::Audios;

ResourceManager ResourceManager::instance;

void ResourceManager::AddTexture(string TextureName, string file) {

Texture *texture = new Texture();

texture->load(CurrentRenderer, file.c_str());

Textures[TextureName] = texture;

}

void ResourceManager::RenderTexture(string TextureName, int x, int y) {
Textures[TextureName]->Render(x, y);
}

void ResourceManager::AddAudio(string AudioName, string file) {
Audio *audio = new Audio();

audio->LoadAudio(file);

Audios[AudioName] = audio;
}

void ResourceManager::SetRenderer(SDL_Renderer *renderer) { CurrentRenderer = renderer; }

ResourceManager* ResourceManager::GetInstance() { return &ResourceManager::instance; };

Possibly PlayAudioand AddAudio do not have 64-bit parameters? I'm on Mac OS X Yosemite with Xcode 6.

2
  • 1
    Well, but where is your code for ResourceManager::PlayAudio(string AudioName, bool Loop) and your Audio() constructor ?
    – nos
    May 22, 2015 at 8:45
  • @nos Fixed. I had to define an empty body for my constructor and define the body for PlayAudio. Thanks for the heads up. May 22, 2015 at 9:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.