我正在使用SDL和C ++制作一个突破性测试游戏,但我遇到了以下构建错误:
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
以下是我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);
};
这是我的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; };
可能PlayAudio
和AddAudio
没有64位参数?我在Mac OS X Yosemite上使用Xcode 6。