Sign in to follow this  

Strange linker error, VC++

Recommended Posts

Hi. I'm currently trying to make a simple game - but I've encountered a slight problem.. Without any errors visible to me, I get a linker error: error LNK2019: unresolved external symbol "public: bool __thiscall CSprite::LoadImageA(char *)" (?LoadImageA@CSprite@@QAE_NPAD@Z) referenced in function "public: bool __thiscall CEngine::Initialize(int,int,int,bool)" (?Initialize@CEngine@@QAE_NHHH_N@Z) I know what the error message MEANS (which is that it doesn't find the definition of a declared function), the problem is just that it seems to me that all is ok. I have made a class called CSprite, which are defined in the file sprite.h. I have made a source file called sprite.cpp, which includes sprite.h, and defines all the member functions. I then create a CSprite instance, and call the LoadImage function. Sprite class declaration:
class CSprite
	SDL_Surface *m_Bitmap;	//bitmap surface with all frames

	CSprite(char * sPath);

	bool LoadImage(char * sPath);
	void Draw(int x, int y, SDL_Surface *Screen);
#include "sprite.h"

bool CSprite::LoadImage(char * sPath)
	m_Bitmap = SDL_LoadBMP(sPath);
	if (m_Bitmap == NULL)
		return false;

	return true;
(I didn't include the other functions here to save space) One thing I tried, which worked, was renaming the member function to LoadImageA (which is the exact name which appears in the linker error message). Any suggestions to what could be the problem here? :) Any help is appreciated. Regards

Share this post

Link to post
Share on other sites
It's probably one of the windows headers #define-ing LoadImage to LoadImageA (there are a few of these done by windows to select either ASCII (ending in A) or Unicode (ending in W) functions. You could try adding something like:
#ifdef LoadImage
#undef LoadImage

to your header file.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this