title: Why am I getting a symbol lookup error?
body: <p>I am writing a library, which is dynamically loaded in my main-application with dlsym.
  I have the following files:</p>
  
  <p>library.h</p>
  
  <pre><code>#include &lt;ilibrary.h&gt;
  #include &lt;igateway.h&gt;
  
  class LibraryImpl;
  
  class Library: public ILibrary {
  public:
      static ILibrary* instance();
  
      IGateway* getGateway() const;
  
  protected:
      Library();
      virtual ~Library();
  
  private:
      static ILibrary* instance_;
      LibraryImpl* library_;
  };
  
  extern "C" {
      IMPORT_EXPORT ILibrary* getLibrary();
  }
  </code></pre>
  
  <p>library.cpp</p>
  
  <pre><code>#include "library.h"
  
  #include "business/BCGateway.h"
  
  
  class LibraryImpl {
  public:
      IGateway* getGateway();
  };
  
  IGateway* LibraryImpl::getGateway() {
      return BCGateway::instance();
  }
  
  
  
  ILibrary* Library::instance_ = NULL;
  ILibrary* Library::instance() {
      return instance_ ? instance_ : (instance_ = new Library);
  }
  
  Library::Library() {
      library_ = new LibraryImpl();
  }
  
  Library::~Library() {
      delete library_;
  }
  
  IGateway* Library::getGateway() const {
      return library_-&gt;getGateway();
  }
  
  
  extern "C" {
      IMPORT_EXPORT
      ILibrary* getLibrary(){
          return Library::instance();
      }
  }
  </code></pre>
  
  <p>business/BCGateway.h</p>
  
  <pre><code>#include &lt;igateway.h&gt;
  
  class BCGateway: public IGateway {
  public:
      static IGateway* instance();
  
  protected:
      BCGateway();
  
  private:
      static IGateway* instance_;
  };
  </code></pre>
  
  <p>business/BCGateway.cpp</p>
  
  <pre><code>#include "BCGateway.h"
  
  IGateway* BCGateway::instance_ = NULL;
  IGateway* BCGateway::instance(){
      return instance_ ? instance_ : (instance_ = new BCGateway);
  }
  </code></pre>
  
  <p>I can connect to the library and successfully load the Library-instance. But when I call library->getGateway() in my main-app I get the following error:</p>
  
  <blockquote>
    <p>symbol lookup error: ./gateways/libSwisscomXtraZone.so: undefined symbol: _ZN9BCGateway8instanceEv</p>
  </blockquote>
  
  <p>Can you please give me a hint, how I can resolve this? I'm stuck.</p>
  
  <p>Thanks.</p>