Problem using a CDialog derived class in a DLL
Dear co-sufferers,
please consider the following problem:
I have a class cNWCLanguageDialog which is derived from CDialog
and resides in a DLL.
Now I want to derive a class cDelFilesDlg (which resides in a different DLL)
from this class.
Step 1: I use class wizard to derive cDelFilesDlg from CDialog
--> everything compiles, links, works.
Step 2: In cDelFilesDlg.cpp and cDelFilesDlg.h, I replace all occurrences
of CDialog by cNWCLanguageDialog
--> everything compiles but doesn't link.
The error msg I get is (translated from German):
cDelFilesDlg.obj : error LNK2001: Unresolved external symbol
"protected: static struct AFX_MSGMAP const cNWCLanguageDialog::messageMap"
(?messageMap@cNWCLanguageDialog@@1UAFX_MSGMAP@@B)
My guess: the problem arises because the two classes
cDelFilesDlg and cNWCLanguageDialog are
in different DLLs. (Reason: I have another class derived
from cNWCLanguageDialog which works fine
but is in the same DLL as cNWCLanguageDialog).
cNWCLanguageDialog is marked as AFX_EXT_CLASS,
the .LIB file of its DLL has been used
for linking with the other DLL.
WHAT's going on here???
All suggestions welcome, of course!
Thanks
Norbert
Re: Problem using a CDialog derived class in a DLL
Because you derived Class X from the Class Y in the other DLL, the linker needs access to the base Class member functions which are in the .obj file from your other DLL. I suggest that you include the relevant .cpp and .h files from the other DLL project into your new DLL project. Then it should link correctly.
HTH
Roger Allen