C++中的DLL导出和继承

Ido*_*dov 5 c++ dll inheritance export

我试图从这样的DLL导出一个类及其基类:

#ifdef MY_EXPORTS
    #define DECLSPEC_TEST __declspec(dllexport)
#else
    #define DECLSPEC_TEST __declspec(dllimport)
#endif


class DECLSPEC_TEST BaseClass
{
  // stuff.
};

class DECLSPEC_TEST DerivedClass : public BaseClass
{
  // This class only has a constructor which initializes the class differently.

};
Run Code Online (Sandbox Code Playgroud)

但我尝试在另一个DLL中使用此类,我不断收到错误:

error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: __thiscall DerivedClass::DerivedClass(void)"
 (__imp_??0DerivedClass@@QAE@XZ) referenced in function 
"public: __thiscall SomeOtherClass::SomeOtherClass(void)" (??0SomeOtherClass@@QAE@XZ)  
Run Code Online (Sandbox Code Playgroud)

我还用PE Explorer查看了我的导出DLL,我在导出列表中看不到派生类.

当我尝试在我的其他DLL中使用基类时,它工作正常.

我究竟做错了什么?

Ido*_*dov 3

好吧,我不知道如何解释这一点,但我将派生类构造函数的实现放在 CPP 文件中而不是在类定义中,错误就消失了......
谢谢大家:)