I need in a DLL to use a class, defined in an executable (DLL and executable are compiled by the same compiler). But I don't want the source code of this class definition to be available to DLL, only declaration.
One possible way to do it is to make all the necessary class methods to be virtual
(so that DLL linker will not need these methods' definitions). The disadvantages of this approach:
- I cannot create objects of exported classes
in DLL code using
new
(a have to create additional functions in executable's code). - I have to make all these methods
virtual
, even if otherwise they don't need to bevirtual
.
There is a way to export a class from a DLL to an executable using Microsoft's __declspec(dllexport)
storage-class extended attribute.
Is there a way to export a class from executable to DLL using the same technique?
My old Borland C 6 compiler does not allow me to create import library during the build of executable project. (So, when compiling the DLL, linker gives me unresolved external error messages for all imported non-virtual class methods.) Is it a limitation of this very compiler, or maybe I'm missing something important?