[Help] SYMBOL/LIB REFERENCES

Posts 16 of 6 · Page 1 of 1
[Help] SYMBOL/LIB REFERENCES
safgshfjhfgjfgj !

Trying to get this damn function to work. AFAIK these are only the d3dx9 lib needs to be included. Anyhow, I've got the following:
[PHP]#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")

// (more code)

class SpriteBatch
{
public:
static LPD3DXSPRITE sprite;
static void Initialise(LPDIRECT3DDEVICE9 device)
{
D3DXCreateSprite(device, &sprite);
}
static void Begin(DWORD myFlags)
{
sprite->Begin(myFlags);
}
static void Draw(LPDIRECT3DTEXTURE9 pTexture, const RECT *pSrcRect, const D3DXVECTOR3 *pCenter, const D3DXVECTOR3 *pPosition, D3DCOLOR color)
{
sprite->Draw(pTexture, pSrcRect, pCenter, pPosition, color);
}
static void End()
{
sprite->End();
}
static bool isReady()
{
if (sprite != NULL)
return true;
return false;
}
void dispose()
{
if(sprite != NULL)
sprite->Release();
}
};
[/PHP]

Yet, I get this error:

Code:
error LNK2001: unresolved external symbol "public: static struct ID3DXSprite * SpriteBatch::sprite" (?sprite@SpriteBatch@@2PAUID3DXSprite@@A)
Please help me fix this problem. I've got absolutely NO idea why this is occuring - the correct libs have been imported, as indicated by the MSDN.

Thanks in advance.
got D3DX9.h included?
In your CPP file for this class, add a line:
Code:
LPD3DXSPRITE SpriteBatch::sprite = 0;
The compiler is complaining about your static member not being initialized. Ive had this problem a few times before.
Thanks for your replies.

Quote Originally Posted by Hell_Demon View Post
got D3DX9.h included?
Yes sir!
Quote Originally Posted by mmbob View Post
In your CPP file for this class, add a line:
Code:
LPD3DXSPRITE SpriteBatch::sprite = 0;
The compiler is complaining about your static member not being initialized. Ive had this problem a few times before.
Thanks, I'll check up on this once I'm on y computer. Would you happen to know how having an uninitialised static member is considered an external symbol problem?
Because usually everything in classes have to have an instance to be used. Static members don't need instances to be accessed, yet you haven't initialized the variable yet, so it just throws an external error at you when you try to access it.

Edit: Why make a class if everything is static..? |:
Quote Originally Posted by Void View Post
Because usually everything in classes have to have an instance to be used. Static members don't need instances to be accessed, yet you haven't initialized the variable yet, so it just throws an external error at you when you try to access it.

Edit: Why make a class if everything is static..? |:
Tried it setting teh static sprite to 0, and failed. Either way, I've uhh, scrapped it for a normal class, because it was so much easier than troubleshooting the problem.

Static class = global accessibility without having to declare umm... sessions? (forgot the word). I was going to make a small class that simplified rendering, and had more friendly overloads? :P
Posts 16 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?