verify() for a library with several C files

48 views
Skip to first unread message

Bogdan Opanchuk

unread,
Mar 16, 2014, 8:36:09 PM3/16/14
to pytho...@googlegroups.com
Hello,

I am trying to wrap a library consisting of several C files (and some headers). Verify() (which, according to the documentation, is the preferred way) only takes a source single file as an argument. I cannot call verify() for each of the files separately, since there are inter-unit calls (which are supposed to be resolved at the linking stage). What is the correct way of handling this case? Is there some reason why verify() cannot take a list of source files and compile/link them in the same way as it does for a single file?

Armin Rigo

unread,
Mar 19, 2014, 4:57:55 AM3/19/14
to pytho...@googlegroups.com
Hi,

On 17 March 2014 01:36, Bogdan Opanchuk <mant...@gmail.com> wrote:
> I am trying to wrap a library consisting of several C files (and some
> headers). Verify() (which, according to the documentation, is the preferred
> way) only takes a source single file as an argument.

It's ffi.verify("...", sources=["list", "of", "files"]).


A bientôt,

Armin.

Bogdan Opanchuk

unread,
Mar 20, 2014, 12:10:49 AM3/20/14
to pytho...@googlegroups.com, ar...@tunes.org
Hi Armin,

Thank you for your response. The problem with this solution is that the source files specified this way do not participate in the calculation of the checksum. This can cause the old version of the compiled library to be used after the sources have been updated.

In addition, since in this case C files are distributed with the package, but are not installed (the compiled library is identified by the preamble only), one has to call verify() with different arguments (with and without "sources", in particular) during installation and during usage. Is there some "best practices" example/template of a CFFI-based wrapper package which provides a Python interface to a multi-file C library distributed with the package? So far I've only seen trivial cases with a dlopen() of an existing library or verify() of a single source file. I tried put together such a template myself, but it seems too sophisticated to be correct, and I still have some compilation problems (exported functions are missing in the installed library, but present if you just build the package in place).
Reply all
Reply to author
Forward
0 new messages