[SOLVED] Adding List to TinyMudServer Yields Linker Errors

Posted by Arew264 on Sun 31 Dec 2006 03:38 AM — 6 posts, 21,210 views.

#0
I have been trying to add a list to tinymudserver. It is a list of an object I have added called tArea, which is in its own area.h file. Also in area.h I have put in:

typedef std::list <tArea*> tAreaList;
typedef tAreaList::iterator tAreaListIterator;


To my understanding, this is defining the datatype tAreaList as a list of pointers to tArea objects, and defining an iterator for that list of pointers to tArea objects.
To create a global area list, I have added

#include "area.h"


to globals.h and then added the line:

extern tAreaList arealist;


to define the global area list. To my understanding this should create a global list of areas, yet when I try to use the area list, g++ compiles it fine but I get linker errors:

undefined reference to `_arealist'

These errors occur whenever I try to use the area list, but in case it matters I am including both globals.h and area.h and the first line of this code throws the error:

     for(tAreaListIterator iter = arealist.begin(); iter != arealist.end(); iter++)
     {
          (*iter)->LoadArea();
     }


There is probably something blaringly obvious that I am doing wrong here, but I can't see it and I am going nuts trying to figure this out.
Amended on Sun 31 Dec 2006 03:50 AM by Arew264
#1
Just realized I have a typo in the subject line, and something odd happened with the fonts in my post. Shame I can't edit it. Sorry to anyone that is bothered by it.
USA #2
You should be able to edit your post title, and post.
#3
Well, I feel like an idiot. I'm guessing that line in globals.h serves as a "prototype"?

I added

tAreaList arealist;

to globals.cpp and the whole thing started working.

Thanks for putting great reference materials on here, what tipped me off was your implementation of classes in the Tinymudserver v2 topic.
#4
Ah, I can't edit the subject but I fixed the font problem.

I'm used to logging in when I post and the system keeping me logged in.
USA #5
There should be a "Amend subject description" link to do that.