Jump to content
  • Advertisement
Sign in to follow this  
hallgeir

Strange linker error, VC++

This topic is 4188 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
{
private:
	SDL_Surface *m_Bitmap;	//bitmap surface with all frames

public:
	//constructors
	CSprite();
	CSprite(char * sPath);

	bool LoadImage(char * sPath);
	void Draw(int x, int y, SDL_Surface *Screen);
};
Definition:
#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
Advertisement
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
#endif

to your header file.

Share this post


Link to post
Share on other sites
By coincidence, somebody else posted about the same exact problem two weeks ago.

http://www.gamedev.net/community/forums/topic.asp?topic_id=439351

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!