Jump to content
  • Advertisement
Sign in to follow this  
steeg

STL map problem

This topic is 4562 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

Hello, I'm a newbie using STL, and have been trying to setup a map for resource management within my game, but keep getting a linkage problem. Here is the code for the header file:
#ifndef RESMANAGER_H
#define RESMANAGER_H
#include <map>
#include <string>
#include "SDL.h"

class CResManager {
public:
	static CResManager* get() {
		return &instance;
	}
protected:
	CResManager(void);
	virtual ~CResManager(void);
private:
	static CResManager instance;
	std::map<std::string, SDL_Surface*> images;
};
#endif

I thought it had something to do with the fact that I was storing pointers, but even a simpl std::map<std:string, std:string> gives an error. Any help is appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I bet the linker is complaining about the static instance; "unresolved external" or some such.

steeg, your static CResManager instance; is only a declaration, you still need to add CResManager CResManager::instance; to some CPP file to define the variable.

Share this post


Link to post
Share on other sites
Quote:
Original post by Fruny
I bet the linker is complaining about the static instance; "unresolved external" or some such.

steeg, your static CResManager instance; is only a declaration, you still need to add CResManager CResManager::instance; to some CPP file to define the variable.


yes, I have that on my .cpp file, which is just blank right now:

#include "ResManager.h"

CResManager CResManager::instance;

CResManager::CResManager(void) {
}

CResManager::~CResManager(void) {
}



and the error I am getting (say when I use std::map<std:string, std:string> is:

ResManager.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: bool __thiscall std::_Tree (and it goes on for lines and lines...)

Share this post


Link to post
Share on other sites
Quote:
Original post by steeg
and the error I am getting (say when I use std::map<std:string, std:string> is:

ResManager.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: bool __thiscall std::_Tree (and it goes on for lines and lines...)


This is a build settings issue. Creating a new project and copying your source files into it should fix it.

A quick [google] turns up people who have had the same problem (and had other less drastic possible solutions, if you have a bunch of custom build settings you'd rather not trash)

Share this post


Link to post
Share on other sites
Or you can make sure that "Ignore All Default Libraries" is set to No (Project->Properties->Configuration Properties->Linker->Input).


jfl.

Share this post


Link to post
Share on other sites
Original post by steeg
Quote:
Original post by Fruny
and the error I am getting (say when I use std::map<std:string, std:string> is:

ResManager.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: bool __thiscall std::_Tree (and it goes on for lines and lines...)
Ah. You aren't using VS2005 Express by chance, are you?

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!