J
Jaco Naude
Hi again,
I will try to post as much information as possible about my error this
time. I am trying to develop a Subject/Observer system (as described
here http://www.codeproject.com/KB/architecture/observer_with_templates.aspx).
Everything works and compiles up to the point where my dll is created
and it fails with the following linking error:
(.text$_ZN11DataManagerC1Ev[DataManager:ataManager()]+0xd):
undefined reference to `Observer<SubjectType<IData*> >::Observer()'
The data manager class is defined as follows and is located along with
all the Observer classes etc. in a different library (dll) which I'm
sure works because I can link to other functions in that dll:
class DataManager : public Observer<SubjectType<IData*> >
public:
//! Object constructor.
DataManager() {}
//! Object desctructor.
~DataManager() {}
The Observer class is defined as follows:
template <class T>
class ObserverData;
template <class T>
class Observer {
public:
//! Object constructor.
Observer();
//! Object desctructor.
virtual ~Observer();
private:
ObserverData<T>* d;
};
And the implementation of the Observer class is done like this:
template <class T>
class ObserverData {
public:
ObserverData() {}
~ObserverData() {}
QMap<QString,T*> object_map;
int subject_limit;
};
//! Object constructor.
template <class T>
Observer<T>::Observer() {
d = new ObserverData<T>();
d->subject_limit = 1;
}
//! Object desctructor.
template <class T>
Observer<T>::~Observer() {
delete d;
}
I've been trying to figure this out for quite some time now and can't
figure out why it does not work. Am I inheriting correctly from the
Observer class?
Please help. Thanks for your time again.
Jaco
I will try to post as much information as possible about my error this
time. I am trying to develop a Subject/Observer system (as described
here http://www.codeproject.com/KB/architecture/observer_with_templates.aspx).
Everything works and compiles up to the point where my dll is created
and it fails with the following linking error:
(.text$_ZN11DataManagerC1Ev[DataManager:ataManager()]+0xd):
undefined reference to `Observer<SubjectType<IData*> >::Observer()'
The data manager class is defined as follows and is located along with
all the Observer classes etc. in a different library (dll) which I'm
sure works because I can link to other functions in that dll:
class DataManager : public Observer<SubjectType<IData*> >
public:
//! Object constructor.
DataManager() {}
//! Object desctructor.
~DataManager() {}
The Observer class is defined as follows:
template <class T>
class ObserverData;
template <class T>
class Observer {
public:
//! Object constructor.
Observer();
//! Object desctructor.
virtual ~Observer();
private:
ObserverData<T>* d;
};
And the implementation of the Observer class is done like this:
template <class T>
class ObserverData {
public:
ObserverData() {}
~ObserverData() {}
QMap<QString,T*> object_map;
int subject_limit;
};
//! Object constructor.
template <class T>
Observer<T>::Observer() {
d = new ObserverData<T>();
d->subject_limit = 1;
}
//! Object desctructor.
template <class T>
Observer<T>::~Observer() {
delete d;
}
I've been trying to figure this out for quite some time now and can't
figure out why it does not work. Am I inheriting correctly from the
Observer class?
Please help. Thanks for your time again.
Jaco