Original Post
I've been trying to get the source that came along with the book "MUD Game Programming" to actually work. I've managed to patch quite a few a bugs, but I am currently stuck on this, and several variations, linker error:
AccountAccessor.o(.gnu.linkonce.t._ZN9BetterMUD11MapDatabaseINS_7AccountEE3getEi+0xd9): In function `BetterMUD::MapDatabase<BetterMUD::Account>::get(int)':
: undefined reference to `BetterMUD::Exception::~Exception [in-charge]()' I cannot determine what is wrong. The custom exception class is contained in a header file which looks like this: #ifndef BETTERMUDEXCEPTION_H
#define BETTERMUDEXCEPTION_H
#include <stdexcept>
#include <string>
namespace BetterMUD
{
class Exception : public std::exception
{
public:
Exception( std::string p_err = "UNDEFINED ERROR" )
: m_err( p_err ) {};
std::string GetError() { return m_err; };
~Exception() throw();
protected:
std::string m_err;
};
} // end namespace BetterMUD
#endif The other class that I think may be relevant looks like this: template< typename entity >
class MapDatabase : public Database< entity, std::map<entityid, entity> >
{
public:
typedef typename std::map<entityid, entity> container;
typedef typename container::iterator iterator;
typename container::iterator begin() { return m_container.begin(); }
typename container::iterator end() { return m_container.end(); }
bool isvalid( entityid p_id )
{
return m_container.find( p_id ) != m_container.end();
}
entity& get( entityid p_id )
{
typename container::iterator itr = m_container.find( p_id );
if( itr == m_container.end() )
throw Exception( "Out of bounds error in map database" );
return itr->second;
}
entity& create( entityid p_id )
{
entity& e = m_container[p_id];
e.SetID( p_id );
return e;
}
void erase( entityid p_id )
{
typename container::iterator itr = m_container.find( p_id );
m_container.erase( itr );
}
entityid FindOpenID()
{
if( m_container.size() == 0 )
return 1;
if( m_container.size() == m_container.rbegin()->first )
return m_container.size() + 1;
entityid openid = 0;
entityid previous = 0;
typename container::iterator itr = m_container.begin();
while( !openid )
{
if( itr->first != previous + 1 )
openid = previous + 1;
else
previous = itr->first;
++itr;
}
return openid;
}
entityid findname( const std::string& p_name )
{
typename container::iterator itr = m_container.begin();
stringmatchfull matcher( p_name );
while( itr != m_container.end() )
{
if( matcher( itr->second.Name() ) )
return itr->first;
++itr;
}
return 0;
}
}; // end class MapDatabase Both of these come from header files. All associated modules compile without errors. When it comes time to link everything together, the makefile just links all the .o's in the directory. Also, I am running gcc3.3. Any help would be incredibly handy at this point. Thank you.