title: DLL export and inheritance in C++
body: <p>I'm trying to export a class and its base class from a DLL like this:  </p>
  
  <pre><code>#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.
  
  };
  </code></pre>
  
  <p>But I try to use this class in another DLL, I keep getting an error:</p>
  
  <pre><code>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)  
  </code></pre>
  
  <p>I also looked at my exporting DLL with PE Explorer and I can't see the derived class in the exports list.  </p>
  
  <p>When I try to use the base class in my other DLL it works fine.</p>
  
  <p>What am I doing wrong?  </p>