Re: crossing dll boundary ...

Tech-Archive recommends: Fix windows errors by optimizing your registry



David Ching wrote:

I would guess you are static linking DllA to Dll main... this means you link Dll main with the DllA.lib import lib. This is called static linking. Dynamic linking if calling LoadLibrary/GetProcAddress instead. These don't work with exported functions. The only way AFAIK to use exported classes in another DLL is to statically link.

Anyway, since both DLL's are loaded into the same process, the class is instantiated in the process heap. I think this heap is used by all DLL's and doesn't "belong" to any one DLL. So the "m" member data is stored in the process heap.

The member functions are exported functions in DllA. They reside in DllA. If you call them from Dll main, it is an indirect call through a function pointer in the IAT (import address table) for the DLL. So technically, it is an extra level of indirection to call an exported function. Nowadays this level of indirection is considered insignificant. So I think you are fine the way it is.

David:

I think what you are talking about here is the distinction between "implicit linking" (using a static import library) and "explicit linking" (using ::LoadLibrary and ::GetProcAddress).

Your terminology of "static linking" versus "dynamic linking" is confusing, IMHO. Firstly, a DLL (as its name implies) is always "dynamically linked", in the sense that the actual code is only linked at run time. Secondly, the terms "static" and "dynamic" linking are commonly used to indicate the way in which the CRT/MFC/C++ libraries are linked, which is another issue entirely.

David Wilkinson
.



Relevant Pages

  • Re: crossing dll boundary ...
    ... variables in dll Main during the compile time. ... Dynamic linking if calling LoadLibrary/GetProcAddress instead. ... The member functions are exported functions in DllA. ...
    (microsoft.public.vc.mfc)
  • Re: "Windows Programing" beginner questions concerning libraries
    ... "dynamic linking or static linking", which is up to personal taste and ... MS would appear to prefer us to use the DLL run-time - there's a story ...
    (microsoft.public.vc.language)
  • Re: "Windows Programing" beginner questions concerning libraries
    ... "dynamic linking or static linking", which is up to personal taste and ... reason I want my .DLL to have it's own copy of the CRT, ... if I have to libraries and one is compiled ...
    (microsoft.public.vc.language)
  • Re: incremental build not optimal?
    ... >> Linking is never a part of the .NET Framework concept. ... > version of my application without the dependencies. ... > multiple clients that you have written, ... > your DLL retains backward compatibility. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Turning off name-decoration
    ... different parameter lists (function overloading). ... Initializewhen it comples the DLL and the APP. ... When you compile the DLL you define _EXPORTS, which declares ... declares the exported functions as __declspec. ...
    (microsoft.public.vc.language)