title: SWIG Python undefined symbol error
body: <p>I'm trying to create a *.so file for further use in Python using SWIG, but something isn't working.</p>
  
  <p>I have two files:
  DataGatherer.h</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include "gnublin.h"
  #include &lt;pthread.h&gt;
  
  class dataGatherer
  {
      private:
      int threshold;
      int timeThreshold;
      int data[4096];
      bool running;
      gnublin_spi* spiDevice;
      pthread_t spiThread;
      void *params;
  
      public:
  
      dataGatherer(void);
      dataGatherer(int, int);
      void initData();
      int getThreshold(void);
      int* getData(void);
      int getPeak(void);
      void initSPI(void);
      void gatherData();
  
      void * run(void * arg);
      void stop(void);
  
      // for use of thread we have to implement some methods from C
      static void * start_static(void * params)
      {
          dataGatherer * thread_this = static_cast&lt;dataGatherer*&gt;(params);
          return thread_this-&gt;run(thread_this-&gt;params);
      }
  
      void start(void * params)
      {
          this-&gt;params = params;
          pthread_create(&amp;spiThread, 0, &amp;dataGatherer::start_static, this);
      }
  
  };
  </code></pre>
  
  <p>and spiController.h</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "dataGatherer.h"
  
  class spiController
  {
      private:
      bool runGather;
      dataGatherer* gatherer;
      int data[4096];
  
      public:
      spiController(void);
      spiController(int, int);
      void initData();
      bool checkStop();
      void stop();
      void start();
  };
  </code></pre>
  
  <p>My spiController.i interface file looks like this:</p>
  
  <pre><code>/* spiController.i */
  %module spiController
  %{
  #include "dataGatherer.h"
  #include "spiController.h"
  #include "gnublin.h"
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;pthread.h&gt;
  extern void initData();
  extern bool checkStop();
  extern void stop();
  extern void start();
  %}
  
  extern void initData();
  extern bool checkStop();
  extern void stop();
  extern void start();
  </code></pre>
  
  <p>At the end I try to create the *.so file using commands in the terminal like in the example on the SWIG page with:</p>
  
  <pre><code>swig -python -c++ spiController.i
  c++ -c spiController_wrap.c -I/usr/include/python2.7
  c++ -shared spiController_wrap.o -o _spiController.so
  </code></pre>
  
  <p>*.cxx, *.o and *.so file are created with no error, but when I import the spiController into the python code I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "spiController.py", line 26, in &lt;module&gt;
      _spiController = swig_import_helper()
    File "spiController.py", line 22, in swig_import_helper
      _mod = imp.load_module('_spiController', fp, pathname, description)
  ImportError: ./_spiController.so: undefined symbol: _Z9checkStopv
  </code></pre>
  
  <p>It's my first try using SWIG and I'm already stuck at this point. How can I resolve this?</p>