Warum hab ich diese Linker fehler
-
Hallo,
ich habe folgenden code unter VC++
class BENTGINE_API DirectSound { private: //variables static BOOL m_bInitialized; //Initialized static LPDIRECTSOUND8 m_pDSound; //IDirectSound8 interface static LPDIRECTSOUNDBUFFER m_pPrimaryBuffer; //Primary Soundbuffer static LPDIRECTSOUND3DLISTENER8 m_pListener; //Listener interface static mathVector3 m_vOldListenerPos; //Time stamper of the SetListener methode public: //methods static Engine_Result Init(Config* pConfig, HWND hWindow=NULL, DWORD dwCoopLevel=DSSCL_PRIORITY, BOOL b3D=TRUE); static Engine_Result Exit(); static Engine_Result SetListener(const mathVector3& vListenerPos, const mathVector3& yListenerYAxis, mathVector3& vListenerZAxis, const float fSpeedFactor=1.0f); //inline methods static inline BOOL IsInitialized() {return m_bInitialized;} static inline LPDIRECTSOUND8 GetDSound() {return m_pDSound;} static inline LPDIRECTSOUNDBUFFER GetPrimaryBuffer() {return m_pPrimaryBuffer;} static inline LPDIRECTSOUND3DLISTENER8 GetListener() {return m_pListener;} static inline mathVector3 GetOldListenerPosition() {return m_vOldListenerPos;} };
und erhalte folgende Fehlermeldungen
DirectSound.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
Config.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
bentgine.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
logbook.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
utils.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
Matrix.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
Memory.obj : error LNK2001: unresolved external symbol "private: static int DirectSound::m_bInitialized" (?m_bInitialized@DirectSound@@0HA)
DirectSound.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
Config.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
bentgine.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
logbook.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
utils.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
Matrix.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
Memory.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound8 * DirectSound::m_pDSound" (?m_pDSound@DirectSound@@0PAUIDirectSound8@@A)
DirectSound.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
Config.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
bentgine.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
logbook.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
utils.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
Matrix.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
Memory.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSoundBuffer * DirectSound::m_pPrimaryBuffer" (?m_pPrimaryBuffer@DirectSound@@0PAUIDirectSoundBuffer@@A)
DirectSound.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
Config.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
bentgine.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
logbook.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
utils.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
Matrix.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
Memory.obj : error LNK2001: unresolved external symbol "private: static struct IDirectSound3DListener * DirectSound::m_pListener" (?m_pListener@DirectSound@@0PAUIDirectSound3DListener@@A)
DirectSound.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
Config.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
bentgine.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
logbook.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
utils.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
Matrix.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
Memory.obj : error LNK2001: unresolved external symbol "private: static class mathVector3 DirectSound::m_vOldListenerPos" (?m_vOldListenerPos@DirectSound@@0VmathVector3@@A)
Release/bentgine.dll : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.Warum ist das so?
Mfg
TheGamer
-
Statische Membervariablen musst du zusätzlich zur Deklaration im Header noch in einer Quelltextdatei definieren:
// .h class C { static int i; }; // .cpp int C::i;