Hey guys, I'm getting a linker error in MSVC++, and it is escaping me. I can't seem to find the unresolved external symbol myself, so I thought I might post the code up here really quick and see if yall can help me find it.
The code isn't too long, so you shouldn't worry too much. Of course linker errors are always kind of cryptic, but here is the actual error itself:
1>animation.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: struct ANIMATION_DATA * & __thiscall std::vector<struct ANIMATION_DATA *,class std::allocator<struct ANIMATION_DATA *> >:
perator[](unsigned int)" (??A?$vector@PAUANIMATION_DATA@@V?$allocator@PAUAN IMATION_DATA@@@std@@@std@@QAEAAPAUANIMATION_DATA@@ I@Z)
So it looks like the unresolved external has something to do with my AnimationList vector inside of my ANIMATION_MANAGER. It is a vector of type ANIMATION_DATA.
Here is the .h header file:
Code:
#ifndef __ANIMATION_DTP_H
#define __ANIMATION_DTP_H
#include <vector>
using namespace std;
#include "SDL.h"
/**************************
ANIMATION_DATA
A structure meant for holding
all data needed for animations
**************************/
struct ANIMATION_DATA
{
SDL_Surface *surfaceData;
int WidthPerFrame, HeightPerFrame;
int FrameCount, SequenceCount;
ANIMATION_DATA ( );
~ANIMATION_DATA ( );
};
/***************************
ANIMATION_MANAGER
A class that manages all
ANIMATION_DATA structures
***************************/
class ANIMATION_MANAGER
{
private:
void Copy ( const ANIMATION_MANAGER & copy );
protected:
vector < ANIMATION_DATA * > AnimationList;
public:
//Constructors
ANIMATION_MANAGER ( );
ANIMATION_MANAGER ( const ANIMATION_MANAGER & copy );
ANIMATION_MANAGER ( char *descriptorFile );
//Destructors
~ANIMATION_MANAGER ( );
//Accessors
ANIMATION_DATA *GetAnimation ( int index );
//Modifiers
void ClearAnimations ( );
//Actions
void LoadFile ( char *descriptorFile );
//Operators
void operator = ( const ANIMATION_MANAGER & copy );
};
Here is the .cpp file:
Code:
#include <fstream>
#include <string>
using namespace std;
#include "SDL.h"
#include "animation.h"
#include "shared.h"
/*************************
ANIMATION_DATA structure
*************************/
ANIMATION_DATA::ANIMATION_DATA ( )
{
surfaceData = NULL;
}
ANIMATION_DATA::~ANIMATION_DATA ( )
{
if ( surfaceData ) SDL_FreeSurface ( surfaceData );
}
/*************************
ANIMATION_MANAGER class
*************************/
void ANIMATION_MANAGER::Copy ( const ANIMATION_MANAGER & copy )
{
AnimationList = copy.AnimationList;
}
//Constructors
ANIMATION_MANAGER::ANIMATION_MANAGER ( )
{
//Empty
}
ANIMATION_MANAGER::ANIMATION_MANAGER ( const ANIMATION_MANAGER & copy )
{
Copy ( copy );
}
ANIMATION_MANAGER::ANIMATION_MANAGER ( char *descriptorFile )
{
LoadFile ( descriptorFile );
}
//Destructors
ANIMATION_MANAGER::~ANIMATION_MANAGER ( )
{
ClearAnimations();
}
//Accessors
ANIMATION_DATA *ANIMATION_MANAGER::GetAnimation ( int index )
{
return AnimationList[index];
}
//Modifiers
void ANIMATION_MANAGER::ClearAnimations ( )
{
for ( unsigned int x = 0; x < AnimationList.size(); x++ )
{
delete AnimationList[x];
AnimationList[x] = NULL;
}
AnimationList.clear();
}
//Actions
void ANIMATION_MANAGER::LoadFile ( char *descriptorFile )
{
//The bulk of the work is done here.
ifstream load;
load.open ( descriptorFile );
string input;
vector < string > tokens;
ANIMATION_DATA *temp = NULL;
while ( !load.eof() )
{
//Clear the tokens vector
tokens.clear();
temp = new ANIMATION_DATA;
//Get the new input line
getline ( load, input );
Tokenize ( input, tokens, " " );
if ( tokens.size() < 5 ) return;
//Process the animation data
temp->surfaceData = SDL_LoadBMP ( tokens[0].c_str() );
SDL_SetColorKey ( temp->surfaceData, SDL_SRCCOLORKEY | SDL_RLEACCEL ,
SDL_MapRGB(temp->surfaceData->format, 255, 0, 255) );
temp->HeightPerFrame = atoi ( tokens[1].c_str() );
temp->WidthPerFrame = atoi ( tokens[2].c_str() );
temp->FrameCount = atoi ( tokens[3].c_str() );
temp->SequenceCount = atoi ( tokens[4].c_str() );
//Push the new animation onto the animation list
AnimationList.push_back ( temp );
//NULL out the pointer to the animation data.
temp = NULL;
}
return;
}
//Operators
void ANIMATION_MANAGER::operator = ( const ANIMATION_MANAGER & copy )
{
Copy ( copy );
}
Anyways, hopefully we can find this linking error. Thanks for any help.