title: C++ Undefined reference errors to the constructors and destructors of the classes which are inside a shared library
body: <p>Ok, I am very new in C++ development. This question may be silly but I can not find its response in any tutorial, book, question/response. It would be great if somebody can kindly explain it to me.</p>
  
  <p>I have 1 header-source pair inside of a shared library libdummy.so:</p>
  
  <p>This is dummy.h:</p>
  
  <pre><code>class dummy
  {
      public:
      ~dummy();
      dummy();
  
      bool dosomething(int a);
  };
  </code></pre>
  
  <p>and this is dummy.cpp:</p>
  
  <pre><code>#include "dummy.h"
  
  dummy::dummy()
  {
  //some assignments here
      clear();
  }
  
  dummy::~dummy()
  {
  clear();
  }
  
  bool dummy::dosomething(int a)
  {
      // do something here
      return true;
  }
  </code></pre>
  
  <p>EDIT: I tell you above the sample codes of dummy.h and dummy.cpp but these files are not in my hand. They are packed inside the library libdummy.so. I have only the libdummy.so shared library file in the hand.</p>
  
  <p>And I have a client to access my shared library.</p>
  
  <p>client.h is here:</p>
  
  <pre><code>#include "dummy.h"
  
  class client
  {
      public:
      void myownjob();
  
      dummy thingy;
  
      //and some functions here
  };
  </code></pre>
  
  <p>and finally this is the client.cpp:</p>
  
  <pre><code>#include "client.h"
  
  void client::myownjob()
  {
      thingy.dosomething(1);
  }
  </code></pre>
  
  <p>Now my problem is; when I try to compile this code, I get undefined reference errors to the constructor and destructor:</p>
  
  <pre><code>error: undefined reference to 'dummy::~dummy()'
  error: undefined reference to 'dummy::dosomething(int)'
  error: undefined reference to 'dummy::dummy()'
  </code></pre>
  
  <p>EDIT: The dummy.h and dummy.cpp are inside libdummy.so. I have only 3 files in the hand: libdummy.so, client.h and client.cpp.</p>
  
  <p>That's why;</p>
  
  <ul>
  <li><p>I can not delete ~dummy(); and dummy(); in the dummy.h to let the compiler creating them automatically. Because dummy.h is inside the libdummy.so shared library. It is not directly editable.</p></li>
  <li><p>I can not do some braceleted empty definitions like ~dummy(){} and dummy(){} in the dummy.h. Because dummy.h is inside the libdummy.so shared library. It is not directly editable.</p></li>
  <li><p>I can not include dummy.cpp to SRC_FILES line of my makefile. Because dummy.cpp is inside libdummy.so shared library. It is not a seperate file.</p></li>
  </ul>
  
  <p>I think this is a very simple/beginner problem, but I can not find its response anywhere. What I have to do to use a class which is inside a shared library, in C++, when I get undefined reference errors to the constructors and destructors?</p>
  
  <p>Thanks in advance.</p>