Just a guess:
If you include the header from dll1 in the dll2 project, and you use __declspec(dllexport)) in this header, you tell the linker that dll2 also exports these classes, which are actually intended to be imported through dll2 , and therefore there is no class definition.
Thus, it would be convenient to use a definition such as this.
#ifdef DLL1_EXPORTS #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT __declspec(dllimport) #endif class DLLEXPORT A {
This design ensures that dll1 definitions are exported when the header is used in dll1 and imported when used inside the dll2 project. All you need is the DLL1_EXPORT macro, which will be defined when dll1 is compiled . Project settings for dll1 are usually a good place.
Another approach is to have two different headers: one to build dll1 and the second to be used with wit dll1 lib (without any __declspec(dllexport) ).
source share