Thread: Unresolved External Symbol

  1. #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.

  2. #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.

Popular pages Recent additions subscribe to a feed

Similar Threads

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