Next: , Previous: Defining a library, Up: Libraries


10.2 Library definition style

Looking at the libcurl library definition presented earlier, you may ask why we did not simply do this:

  (define-foreign-library libcurl
    (t (:default "libcurl")))

Indeed, this would work just as well on the computer on which I tested the tutorial. There are a couple of good reasons to provide the .so's current version number, however. Namely, the versionless .so is not packaged on most unix systems along with the actual, fully-versioned library; instead, it is included in the “development” package along with C headers and static .a libraries.

The reason CFFI does not try to account for this lies in the meaning of the version numbers. A full treatment of shared library versions is beyond this manual's scope; see Library interface versions, for helpful information for the unfamiliar. For our purposes, consider that a mismatch between the library version with which you tested and the installed library version may cause undefined behavior.1

Implementor's note: Maybe some notes should go here about OS X, which I know little about. –stephen

Footnotes

[1] Windows programmers may chafe at adding a unix-specific clause to define-foreign-library. Instead, ask why the Windows solution to library incompatibility is “include your own version of every library you use with every program”.