Building a python interface for a *.so
<p>I want to make use of a <code>C</code> library, from which a shared object and the header files are available. </p>

<p>As the documentation of <code>ctypes</code> and <code>Cython</code> are very scarce and tutorials about those were for different usage, I need some help. </p>

<p>So, I don't know where to start here and which tool would be the easiest solution for a Python beginner like me. </p>

<p>I finally managed to import the library with <code>ctypes</code>. <code>Cython</code> didn't work out for me, and seemed to complex with the different files needed. </p>

<p>After getting an error like: <code>undefined symbol: inflate</code>, the accessing really worked out with importing the needed pcap lib from the system libs. I just didn't knew that it was needed. I found where it is with: <code>find /usr/lib/ -name libpcap*</code></p>

<pre><code>from ctypes import cdll

def main():
    libpcap = cdll.LoadLibrary('path/to/libpcap.so')
    lib = cdll.LoadLibrary('path/to/lib.so')
    lib.function_from_lib

if __name__ == "__main__":
    main()
</code></pre>

<p>So I hope, if anyone has this problem and comes from google, here is a solution which might help.</p>

python shared-libraries cython ctypes