title: Linking a SWIG wrapper with other libraries
body: <p>I have a C++ function that I want to call from Python. The function itself is pretty simple, but it involves an IPC call that can only be done in C++. To compile that C++ code requires linking a ton of other libraries in. I'm trying to use SWIG for this. I have a Makefile that looks like this:</p>
  
  <pre><code>all: swig object shared
  
  object: swig
    ${CC} -c ${MODULE}_wrap.cxx ${INCLUDES}
  
  shared:
    ${CC} -Wl,--verbose -shared ${MODULE}_wrap.o -o _${MODULE}.so
  
  swig:
    ${SWIG} -c++ -python ${MODULE}.i
  </code></pre>
  
  <p>With this, everything compiles fine, but then importing my module in Python gives me "undefined symbol" errors. If I change the <code>shared</code> line to:</p>
  
  <pre><code>shared:
    ${CC} -Wl,--verbose -shared ${MODULE}_wrap.o -o _${MODULE}.so ${LIBS}
  </code></pre>
  
  <p>it fails to compile with <code>collect2: ld returned 1 exit status</code> but doesn't tell me exactly what the error is. The verbose linker output has a ton of lines that say "attempt to open [some lib] failed" but a handful of those lines say "succeeded". Could it just be the ones that say failed are preventing linking from happening? Is what I'm trying to do even possible with SWIG modules?</p>