title: swig - c++ to python. link systemd lib
body: <p>I'm using swig to make a python wrapper for my c/c++ project.</p>
  
  <p>I manage to compile it all but when running python and importing the py file i get </p>
  
  <p><code>ImportError: ./_example.so: undefined symbol:sd_bus_get_property_trivial</code></p>
  
  <p>I'm using systemd lib
  <code>http://www.linuxfromscratch.org/lfs/view/systemd/chapter06/systemd.html</code></p>
  
  <p>in my h file I include the file 
  <code>#include &lt;systemd/sd-bus.h&gt;</code></p>
  
  <p>I think the <code>.so</code> file for <code>systemd</code> lib isn't included automatically with swig, because it's not at the default lib folder. it's at <code>/lib/x86_64-linux-gnu/libsystemd.so</code></p>
  
  <p>How do I include this <code>.so</code> file manually? This is my <code>setup.py</code>:</p>
  
  <pre><code>#!/usr/bin/env python
  
  """
  setup.py file for SWIG simple_ex
  """
  
  from distutils.core import setup, Extension
  
  
  example_module = Extension('_example',
                             sources=['example_wrap.cxx', 'example.cpp'],
                             extra_compile_args=["-o /lib/x86_64-linux-gnu/libsystemd.so"]
                             )
  
  setup (name = '_example',
         version = '0.1',
         author      = "SWIG Docs",
         ext_modules = [example_module],
         py_modules = ["_example"],
         )
  </code></pre>
  
  <p><code>extra_compiled_args=</code> was some experminet to add the lib. Didn't work.</p>
  
  <p>This is my <code>.i</code> file:</p>
  
  <pre><code>/* File: example.i */
  %module example
  
  %include std_vector.i
  %include std_string.i
  %include exception.i
  
  
  %{
  #define SWIG_FILE_WITH_INIT
  #include "example.h"
  %}
  
  %exception {
      try {
          $action
      } catch(...) {
          SWIG_exception(SWIG_RuntimeError, "Unknown exception");
      }
  }
  
  int foo(int a);
  </code></pre>
  
  <p><code>foo</code> uses a function from <code>systemd/sd-bus</code></p>