【发布时间】:2013-04-17 00:09:02
【问题描述】:
错误 LNK2001:无法解析的外部符号“私有:静态类 irrklang::ISoundEngine * GameEngine::Sound::_soundDevice”(?_soundDevice@Sound@GameEngine@@0PAVISoundEngine@irrklang@@A)
我无法弄清楚为什么我会收到此错误。我相信我正在正确初始化。有人可以帮忙吗?
声音.h
class Sound
{
private:
static irrklang::ISoundEngine* _soundDevice;
public:
Sound();
~Sound();
//getter and setter for _soundDevice
irrklang::ISoundEngine* getSoundDevice() { return _soundDevice; }
// void setSoundDevice(irrklang::ISoundEngine* value) { _soundDevice = value; }
static bool initialise();
static void shutdown();
声音.cpp
namespace GameEngine
{
Sound::Sound() { }
Sound::~Sound() { }
bool Sound::initialise()
{
//initialise the sound engine
_soundDevice = irrklang::createIrrKlangDevice();
if (!_soundDevice)
{
std::cerr << "Error creating sound device" << std::endl;
return false;
}
}
void Sound::shutdown()
{
_soundDevice->drop();
}
以及我在哪里使用声音设备
GameEngine::Sound* sound = new GameEngine::Sound();
namespace GameEngine
{
bool Game::initialise()
{
///
/// non-related code removed
///
//initialise the sound engine
if (!Sound::initialise())
return false;
任何帮助将不胜感激
【问题讨论】:
标签: c++ visual-c++ linker-errors static-members