title: ImportError: undefined symbol in _...so file when using SWIG
body: <p>I am using SWIG to convert a C++ code to a python code but I did not succeed to solve the following Import error. I was not able to know the source of the issue</p>
  
  <blockquote>
    <p>ImportError: /.../_RfBm.so: undefined symbol: _ZN5RNormclERSt6vectorIdSaIdEE</p>
  </blockquote>
  
  <p>The RfBm.i file is given by</p>
  
  <pre><code>%module RfBm
  %{   
    #define SWIG_FILE_WITH_INIT
    #include "RfBm.h"
  %}
  %include "RfBm.h"
  </code></pre>
  
  <p>The .cpp file is given by the following code</p>
  
  <pre><code>#include "RfBm.h"
  
  RfBm::RfBm() {
  n = 0;
  H = 0.0;
  gamma = 0.0;
  rnorm = 0;
  L = std::vector&lt;Vector&gt;(0);
  }
  
  double RfBm::A(int i, int j) const {
  double ret = 0.0;
  if((i &lt; n) &amp;&amp; (j &lt; n))
      ret = cBm(i,j);
  else if((i &lt; n) &amp;&amp; (j &gt;= n))
      ret = cMixed(i, j-n);
  else if((i &gt;= n) &amp;&amp; (j &lt; n))
      ret = cMixed(j, i-n);
  else if((i &gt;= n) &amp;&amp; (j &gt;= n))
      ret = cfBm(i-n, j-n);
  return ret;
  }
  
  double RfBm::G(double x) const {
  return 2.0 * H
          * (pow(x, -gamma) / (1.0 - gamma)
                  + gamma * pow(x, -(1.0 + gamma))
                          * gsl_sf_hyperg_2F1(1.0, 1.0 + gamma, 3.0 - gamma,
                                  1.0 / x) / ((1.0 - gamma) * (2.0 - gamma)));
  }
  
  double RfBm::cBm(int i, int j) const {
  return (i == j) ? 1.0 : 0.0;
  }
  
  double RfBm::cfBm(int i, int j) const {
  double t = static_cast&lt;double&gt;(std::min(i,j) + 1) / n;
  double s = static_cast&lt;double&gt;(std::max(i,j) + 1) / n;
  return pow(t, 2*H) * G(s/t);
  }
  
  double RfBm::cMixed(int i, int j) const {
  double ret = 0.0;
  if(i &lt;= j){
      double u = static_cast&lt;double&gt;(i)/n;
      double v = static_cast&lt;double&gt;(i+1)/n;
      double t = static_cast&lt;double&gt;(j+1)/n;
      ret = 2.0 * sqrt(2.0*H*n) * (pow(t - u, 0.5 + H) - pow(t - v, 0.5 + H)) / 
  (1.0 + 2.0 * H);
  }
  return ret;
  }
  
  RfBm::RfBm(int nI, double HI, RNorm* rnormI) {
  n = nI;
  H = HI;
  gamma = 0.5 - H;
  rnorm = rnormI;
  L = std::vector&lt;Vector&gt;(2 * n, Vector(2 * n, 0.0)); // fill with 0s first.
  // Now fill the matrix L.
  for (int k = 0; k &lt; 2 * n; ++k) {
      double temp = 0.0;
      for (int j = 0; j &lt; k; ++j)
          temp += L[k][j] * L[k][j];
      L[k][k] = sqrt(A(k, k) - temp);
      for (int i = k + 1; i &lt; 2*n; ++i) {
          double temp = 0.0;
          for (int j = 0; j &lt; k; ++j)
              temp += L[i][j] * L[k][j];
          L[i][k] = (A(i, k) - temp) / L[k][k];
         }
        }
  }
  
  void RfBm::generate(Vector&amp; W1, Vector&amp; Wtilde) {
  Vector x(2 * n);
  (*rnorm)(x);
  for (int i = 0; i &lt; n; ++i) {
      W1[i] = 0.0;
      for (int j = 0; j &lt;= i; ++j)
          W1[i] += L[i][j] * x[j];
  }
  for (int i = 0; i &lt; n; ++i) {
      Wtilde[i] = 0.0;
      for (int j = 0; j &lt;= (i + n); ++j)
          Wtilde[i] += L[i + n][j] * x[j];
  }
  }
  
  void RfBm::operator ()(Vector&amp; W1, Vector&amp; Wtilde) {
  this-&gt;generate(W1, Wtilde);
  }
  
  std::vector&lt;Vector&gt; RfBm::GetA() const {
  std::vector&lt;Vector&gt; A_mat(2*n, Vector(2*n, 0.0));
  for(int i=0; i&lt;2*n; ++i)
      for(int j=0; j&lt;2*n; ++j)
          A_mat[i][j] = A(i,j);
  return A_mat;
  }
  </code></pre>
  
  <p>The commands I used for compling and linking are:</p>
  
  <pre><code>swig -c++ -python RfBm.i
  g++ -O2 -fPIC -c RfBm.cpp -I/home/.../gsl/include
  g++ -O2 -fPIC -c RfBm_wrap.cxx  -I/home/.../gsl/include
  g++ -shared -o _RfBm.so RfBm.o RfBm_wrap.o -L/home/.../gsl/lib -lgsl 
  -lgslcblas -lm       
  </code></pre>
  
  <p>Any help? thank you.</p>