utsavanand
utsavanand

Reputation: 329

How to use shared dynamic libraries with python-cffi (in linux)?

OS: CentOS 6 (64bit)

I have a dynamic library (.so) in C. And I want to create an abstraction layer of Python over it and then use it to implement my logic. I have decided to use CFFI for this since it doesn't deal with any kind of dsl (domain specific language).

Couple of things I wanted to know:

  1. Is there some good starting point which I can refer for doing this (loading and using dynamic libraries using cffi)? The docs on the official site talk about this, but I was looking if there was some concrete reference somewhere with some examples. Or someone who might have tried it.
  2. Can there a possible drawback to this approach?

Thanks

Upvotes: 3

Views: 2213

Answers (1)

David Wolever
David Wolever

Reputation: 154494

Two good starting points:

Between the two you shouldn't have too much trouble putting together your wrapper.

And to your second question: if the shared library you're wrapping is very simple (ex, a few function calls, simle data structures) you might find ctypes simpler (as it's part of the standard library).

Upvotes: 4

Related Questions