C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-20-2009, 01:45 PM   #1
Registered User
 
Join Date: Feb 2008
Location: Rochester, NY
Posts: 27
Unresolved External Symbol

So I'm playing with binding Lua to C++ for class. I have an example which does the binding correctly. What I am trying to toy with now is sharing objects between Lua scripts which will be referenced by a name.

So I have a Badger class which is binded to Lua via LuaBadger. Now what I have attempted to do is make a BadgerManager class which gets called when the Lua script attempts to create a new Badger. It checks to see if the Badger is already created then returns that Badger. Probably pointless and going about it the wrong way but I'm just kind of playing around at this point.

Issue is that when I attempt to store and use a BadgerManager pointer in my LuaBadger class it is telling me unresolved external symbol. It has to be something with my use of static in the class. Although I'm apparently misunderstanding what I am doing. Any help on resolving the unresolved would be great. Thank!

BadgerManager (part of SimpleLua.h)
Code:
class BadgerManager
{
public: 
	BadgerManager(){ };
	~BadgerManager(){ };

	Badger* GetBadger(const char* name) 
	{
		Badger* b = 0;
		list<Badger*>::iterator itr = badgerList.begin();
		while(itr != badgerList.end())
		{
			if(strcmp(name, (*itr)->GetName()))
			{
				b = (*itr);
				break;
			}
		}

		if(!b)
		{
			(*b) = Badger(name);
		}

		return b;
	};
private:
	list<Badger*> badgerList;
};
Excerpt from LuaBadger (below BadgerManager in SimpleLua.h)
Code:
static BadgerManager* bm;

static int create_badger(lua_State* L)
{
	Badger* b;
	const char* name = luaL_checkstring(L, 1);

	b = (Badger*)lua_newuserdata(L, sizeof(Badger));
	luaL_getmetatable(L, className);
	lua_setmetatable(L, -2);

	//(*b) = Badger(name);
	b = bm->GetBadger(name);

	return 1;
}
If I comment out bm->GetBadger(name) everything compiles fine.
CornyKorn21 is offline   Reply With Quote
Old 01-20-2009, 02:50 PM   #2
Registered User
 
Join Date: Feb 2008
Location: Rochester, NY
Posts: 27
Resolved the issue.
Never initialized the LuaBadger::bm outside of the class definition.
CornyKorn21 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling sample DarkGDK Program Phyxashun Game Programming 6 01-27-2009 03:07 AM
C++ std routines siavoshkc C++ Programming 33 07-28-2006 12:13 AM
Including lib in a lib bibiteinfo C++ Programming 0 02-07-2006 02:28 PM
Stupid compiler errors ChrisEacrett C++ Programming 9 11-30-2003 05:44 PM
debug to release modes DavidP Game Programming 5 03-20-2003 03:01 PM


All times are GMT -6. The time now is 11:13 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22