LNK2019: unresolved external symbol __imp___CrtDbgReportW

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by RandomDever »

Why is it giving me this error?

Code: Select all

LNK2019: unresolved external symbol __imp___CrtDbgReportW
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by Milch »

Well, obviously you didn't link something that is needed.
Give more information and maybe somebody can help you ;)
Follow me on twitter!
User avatar
Boogy
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 27
Joined: Sun Mar 06, 2011 3:59 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Breda, The Netherlands
Contact:

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by Boogy »

Student @ IGAD
Image
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by RandomDever »

@Boogy: Thanks it worked.
Now I'm having problems with this:

Code: Select all

keystates = SDL_GetKeyState( NULL );
It keeps giving me an error:

Code: Select all

Access violation reading location 0xcccccccc
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by Falco Girgis »

...You can't just show us a line of code that is syntactically correct then show us an error. Obviously that's not enough information. =/
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by RandomDever »

GyroVorbis wrote:...You can't just show us a line of code that is syntactically correct then show us an error. Obviously that's not enough information. =/
I apologize.

Here's the header:

Code: Select all

class Input
{
public:
	void Init();
	int Poll();
	bool Type( Uint8 type );
	SDL_Event *Get();
	Uint8 GetKey( int key, int check = INPUT_ISDOWN );
	int GetMouse( int button, int check = INPUT_ISDOWN );
private:
	SDL_Event event;
	Uint8 *keystates;
	bool keyEvents[322][2];
	int mousestates[3];
	bool mouseEvents[3][2];
};
And here's the CPP file:

Code: Select all

void Input::Init()
{
	keystates = SDL_GetKeyState( NULL );
	mousestates[0] = false;
	mousestates[1] = false;
	mousestates[2] = false;
	for( int i = 0; i < 322; i++ )
	{
		keyEvents[i][0] = false;
		keyEvents[i][1] = false;
	}
}

int Input::Poll()
{
	SDL_PumpEvents();
	for( int i = 0; i < 322; i++ )
	{
		keyEvents[i][0] = keyEvents[i][1];
		if( keystates[i] == 0 )
		{
			keyEvents[i][1] = false;
		}
		else
		{
			keyEvents[i][1] = true;
		}
	}

	mousestates[0] = SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON( 1 );
	mousestates[1] = SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON( 2 );
	mousestates[2] = SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON( 3 );
	for( int i = 0; i < 3; i++ )
	{
		mouseEvents[i][0] = mouseEvents[i][1];
		if( mousestates[i] == 0 )
		{
			mouseEvents[i][1] = false;
		}
		else
		{
			mouseEvents[i][1] = true;
		}
	}

	return SDL_PollEvent( &event );
}

bool Input::Type( Uint8 type )
{
	return event.type == type;
}

SDL_Event *Input::Get()
{
	return &event;
}

Uint8 Input::GetKey( int key, int check )
{
	if( check == INPUT_RELEASE )
	{
		if( keyEvents[key][0] == true && keyEvents[key][1] == false )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else if( check == INPUT_PRESS )
	{
		if( keyEvents[key][0] == false && keyEvents[key][1] == true )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	return keystates[key];
}

int Input::GetMouse( int button, int check )
{
	if( check == INPUT_RELEASE )
	{
		if( mouseEvents[button][0] == true && mouseEvents[button][0] == false )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else if( check == INPUT_PRESS )
	{
		if( mouseEvents[button][0] == false && mouseEvents[button][0] == true )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	return mousestates[button - 1];
}
Here's the additional dependencies:

Code: Select all

SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib  OpenGL32.lib glu32.lib
User avatar
Boogy
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 27
Joined: Sun Mar 06, 2011 3:59 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Breda, The Netherlands
Contact:

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by Boogy »

Have you initialized SDL before calling SDL_GetKeyState()?

And are you running in debug mode because release can produce different result
Student @ IGAD
Image
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by RandomDever »

@Boogy: No and yes.
Oops.
Thanks again.
Last edited by RandomDever on Fri Mar 18, 2011 7:50 am, edited 1 time in total.
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: LNK2019: unresolved external symbol __imp___CrtDbgReportW

Post by N64vSNES »

Boogy wrote:Have you initialized SDL before calling SDL_GetKeyState()?

And are you running in debug mode because release can produce different result
This^

And here:

Code: Select all

int Input::GetMouse( int button, int check )
What if button is 0?
Then here:

Code: Select all

return mousestates[button - 1];
You return the index -1 in the array, this should spring a access violation.
Post Reply