I am having a strange problem that no pure virtual function is exporting from a DLL. DLL compiles and outputs as .dll file to the directory . But it doesn't produce .lib file.
If I give definition and it no longer remians as pure virtual, after that happily it creates .lib file.
I need to implement factory pattern for which I need to seperate interfaces and implementations. My factory implementation and other interfaces that use wanted .dll(of whome .lib file is not producing) need to use that exported function and when I use those functions they produce linking errors...
such as "error LNK2011: unresolved external symbol "public:......."
Have any one idea how to export pure virtual functions so that they can be implemented for other exe's and dll's
Regards Usman
following link will clarify you doubts
Using dllimport and dllexport in C++ Classes
Not necessary to export class with only virtual/inline functions
When you export something from a DLL you are creating an externally-visible name for something concrete in that DLL - a defined function or class. Without this, the link step for importing projects (those that reference that DLL) cannot resolve all required references to functions and classes in the exporting DLL.
For pure virtual functions, there is no concrete 'thing' in the exporting DLL: no linkable name can exist to resolve an external call to a pure virtual function - if there were, it would by definition not be pure. In this case, all that's needed is a declaration in a compile-time accessible header file of the pure virtual function, so that importing EXEs or DLLs know how to override it with a concrete function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With