• Advertisement
Sign in to follow this  

Strange linker error

This topic is 3081 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 all, I'm using the following stuff to make a Pong Clone: Editor (IDE): Microsoft Visual C++ 2008 Express Edition Language used: C++ Other stuff used: SDL, SDL_image and SDL_ttf OS: Windows XP VC++ Setup guide used: Lazyfoo's tutorials Project Template: Win32 Console Application The 2 error messages that I get are:
1>Object.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator<class Object *,class std::allocator<class Object *> >::_Vector_const_iterator<class Object *,class std::allocator<class Object *> >(class Object * *,class std::_Container_base_secure const *)" (??0?$_Vector_const_iterator@PAVObject@@V?$allocator@PAVObject@@@std@@@std@@QAE@PAPAVObject@@PBV_Container_base_secure@1@@Z)
1>C:\Documents and Settings\Admin\Dokumenter\Visual Studio 2008\Projects\Pong Clone\Debug\Pong Clone.exe : fatal error LNK1120: 1 unresolved externals

I looked up the error on the Microsoft Developer Network (msdn.com) and I understand what the problem is, but the unresolved symbol is '__imp___CrtDbgReportW' which I have no idea what is. Here is the 'Object.h' and 'Object.cpp' files that the linker refers to:
#ifndef OBJECT_H
#define OBJECT_H

#include <vector>
using namespace std;

#include "Graphics.h"
#include "Animation.h"

class Object
		Object(char* file, int x, int y, int w, int h, int xspeed, int yspeed, int maxframes);

		SDL_Surface* image;
		Animation animation;

		int x;
		int y;
		int w;
		int h;
		int xspeed;
		int yspeed;
		int frame;
		int maxframes;
		bool animate;

		static vector<Object*> ObjectList;

		bool LoadObject(char* file, int w, int h, int maxframes);
		int GetCurrentFrame();
		void LoopObject();
		void RenderObject(SDL_Surface* destination);
		void RemoveObject();


#include "Object.h"

vector<Object*> Object::ObjectList;

Object::Object() {}

Object::Object(char* file, int x, int y, int w, int h, int xspeed, int yspeed, int maxframes)
	LoadObject(file, w, h, maxframes);
	this->x = x;
	this->y = y;
	this->xspeed = xspeed;
	this->yspeed = yspeed;
	animate = false;


bool Object::LoadObject(char* file, int w, int h, int maxframes)
	if((this->image = Graphics::LoadImage(file)) == NULL)
		return false;

	this->w = w;
	this->h = h;
	this->maxframes = maxframes;

	return true;

int Object::GetCurrentFrame()
	return frame;

void Object::LoopObject()

void Object::RenderObject(SDL_Surface* destination)
	if(destination == NULL || image == NULL) {return;}

	if(w == 0 && h == 0)
		Graphics::DrawImage(image, destination, x, y);
		Graphics::DrawImage(image, destination, x, y, frame * w, frame * h, w, h);

void Object::RemoveObject()
	if(image) {SDL_FreeSurface(image);}

	image = NULL;

If you would like me to link the other related headers/sources, please tell me, but there are a lot though :P

Share this post

Link to post
Share on other sites
I found some people on other sites with the same problem. As you correctly point out, my CRT (has something to do with the C runtime library?) has to match my config. I was compiling under Debug with the 'Runtime Library' option set to 'Multi-threaded DLL (/MD)'.

By changing it to 'Multi-threaded Debug DLL (/MDd)' it worked. I also got advice from another site that worked: By changing Project properties-> C/C++ -> Preprocessor -> Preprocessor Definitions from 'WIN32;_DEBUG;_CONSOLE' to 'WIN32;NDEBUG;_CONSOLE', it worked as well.

I don't know which one, if any, is the best though.

Thanks for your help, ChaosEngine! :)

Share this post

Link to post
Share on other sites
I forgot to mention that when changing the Runtime Library as described, I get th following warning (even so, everything compiles and works):

1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

Share this post

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

  • Advertisement