Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have to include <code>liba.so</code> in your PATH, otherwise Python won't know where to look for it.</p> <p>Try the following code, it'll load the library if it can find it from PATH, otherwise it'll try loading it from the directory of the load script</p> <pre><code>from ctypes import * from ctypes.util import find_library import os if find_library('a'): liba = CDLL(find_library('a')) else: # library is not in your path, try loading it from the current directory print 'liba not found in system path, trying to load it from the current directory' print '%s/%s'%(os.path.dirname(__file__),'liba.so') liba = CDLL(os.path.join(os.path.dirname(__file__),'liba.so')) </code></pre> <p><a href="http://docs.python.org/library/ctypes.html#finding-shared-libraries" rel="nofollow">http://docs.python.org/library/ctypes.html#finding-shared-libraries</a></p> <p><strong>UPDATE:</strong> I was wondering why you created a native library (<code>liba</code>) to access a native 3rd party library (<code>libb</code>). You can import the third party c library straight into python using <code>ctypes</code> and create a python (not native) wrapper for <code>libb</code>. For instance to call the standard c lib <code>time</code> you would do</p> <pre><code>&gt;&gt;&gt; from ctypes import * &gt;&gt;&gt; lib_c = CDLL("libc.so.6") &gt;&gt;&gt; print lib_c.time(None) 1150640792 </code></pre> <p>and for libb</p> <pre><code>&gt;&gt;&gt; from ctypes import * &gt;&gt;&gt; lib_b = CDLL("libb") &gt;&gt;&gt; lib_b.hello_world(None) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload