From: Jaime Stuardo on
Hi all...

I have a DLL ( A ) that uses some controls present in another DLL ( B ).

All works well except when I derive a class from a control implemented in
DLL B. That derived class is present in DLL A.

I receive the following linker error:
Linking...
Creating library Debug/Handkey.lib and object Debug/Handkey.exp
Masked.obj : error LNK2001: unresolved external symbol "public: static
struct CRuntimeClass const CSuperEditEx::classCSuperEditEx"
(?classCSuperEditEx(a)CSuperEditEx@@2UCRuntimeClass@@B)
Masked.obj : error LNK2001: unresolved external symbol "protected: static
struct AFX_MSGMAP const CSuperEditEx::messageMap"
(?+messageMap(a)CSuperEditEx@@1UAFX_MSGMAP@@B)
.../Debug/Handkey.bpx : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

By seeing those messages I can realize that the problem is at these lines:

DECLARE_MESSAGE_MAP() in MASKED.H file
and
IMPLEMENT_DYNAMIC(CMaskEdit, CSuperEditEx) in MASKED.CPP file

This is the declaration of the imported class:

class AFX_EXT_CLASS CSuperEditEx : public CEdit
{
DECLARE_DYNAMIC(CSuperEditEx)
...........................
}

As I told, I use this class (CSuperEditEx, present in DLL B) in a lot of
places of DLL A with no problem. The problem existed when I derived a class
from CSuperEditEx.

I have tested all I could do without success. I have even seen the content
of the.LIB file corresponding of DLL B and I saw:
__imp_?classCSuperEditEx(a)CSuperEditEx@@2UCRuntimeClass@@B
and
__imp_?messageMap(a)CSuperEditEx@@1UAFX_MSGMAP@@B

As you see, those strings are almost the same as the shown in the linking
error. That "__imp" makes the difference.

Any help will be greatly appreciated

Jaime


From: Frank Hickman [MVP] on
"Jaime Stuardo" <jstuardo(a)manquehue.net> wrote in message
news:OW8$WWhGFHA.3312(a)TK2MSFTNGP10.phx.gbl...
> Hi all...
>
> I have a DLL ( A ) that uses some controls present in another DLL ( B ).
>
> All works well except when I derive a class from a control implemented in
> DLL B. That derived class is present in DLL A.
>
> I receive the following linker error:
> Linking...
> Creating library Debug/Handkey.lib and object Debug/Handkey.exp
> Masked.obj : error LNK2001: unresolved external symbol "public: static
> struct CRuntimeClass const CSuperEditEx::classCSuperEditEx"
> (?classCSuperEditEx(a)CSuperEditEx@@2UCRuntimeClass@@B)
> Masked.obj : error LNK2001: unresolved external symbol "protected: static
> struct AFX_MSGMAP const CSuperEditEx::messageMap"
> (?+messageMap(a)CSuperEditEx@@1UAFX_MSGMAP@@B)
> ../Debug/Handkey.bpx : fatal error LNK1120: 2 unresolved externals
> Error executing link.exe.
>
> By seeing those messages I can realize that the problem is at these lines:
>
> DECLARE_MESSAGE_MAP() in MASKED.H file
> and
> IMPLEMENT_DYNAMIC(CMaskEdit, CSuperEditEx) in MASKED.CPP file
>
> This is the declaration of the imported class:
>
> class AFX_EXT_CLASS CSuperEditEx : public CEdit
> {
> DECLARE_DYNAMIC(CSuperEditEx)
> ..........................
> }
>
> As I told, I use this class (CSuperEditEx, present in DLL B) in a lot of
> places of DLL A with no problem. The problem existed when I derived a
> class from CSuperEditEx.
>
> I have tested all I could do without success. I have even seen the content
> of the.LIB file corresponding of DLL B and I saw:
> __imp_?classCSuperEditEx(a)CSuperEditEx@@2UCRuntimeClass@@B
> and
> __imp_?messageMap(a)CSuperEditEx@@1UAFX_MSGMAP@@B
>
> As you see, those strings are almost the same as the shown in the linking
> error. That "__imp" makes the difference.
>
> Any help will be greatly appreciated
>
> Jaime

I'd have to see your project settings and files to know for sure but it
looks as if the AFX_EXT_CLASS macro is not being declared correctly or maybe
the DLL(B) import library is not being linked into your project.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp(a)m_ with @ to reply.


From: rajkumar on
The problem is that the DECLARE/IMPLEMENT macro creates some magic
static variables. These are not exported by default.

You may have to redefine your DECLARE/IMLEMENT to say
MY_DECLARE_DYNAMIC etc and export the appropriates things in the
MY_DECLARE_DYNAMIC macro