[cffi-devel] Recommended way to specify libraries

Elliott Slaughter elliottslaughter at gmail.com
Sat Jan 4 01:38:29 UTC 2014


On Thu, Jan 2, 2014 at 1:46 PM, Luke Crook <luke at balooga.com> wrote:

> I don't think that this is such a burden. This is how libs are loaded in
> lisp builder-sdl.
>
>
> (cffi:define-foreign-library sdl
>   (:darwin (:or (:framework "SDL")
>                 (:default "libSDL")))
>   (:windows "SDL.dll")
>   (:unix (:or "libSDL-1.2.so.0.7.2"
>               "libSDL-1.2.so.0"
>               "libSDL-1.2.so"
>               "libSDL.so"
>               "libSDL")))
>

Yeah, we can keep doing that, but I did get some complaints recently from
users who found a new libpng version we hadn't accounted for. And Windows
has no tradition of maintaining multiple names for the same library, so we
can't just assume it'll exist under the name "libpng.dll". I guess if we
stick to our current system we'll just have to push patches every time a
new libpng version is released.


> On Tuesday, December 31, 2013, Luís Oliveira wrote:
>
>> On Tue, Dec 31, 2013 at 6:58 PM, Elliott Slaughter
>> <elliottslaughter at gmail.com> wrote:
>> > with the comment "the define-foreign-library clause (t (:default
>> "libcurl"))
>> > [...] will adapt to various operating systems".
>> >
>> > I'm wondering exactly how smart is this automatic handling?
>>
>> Right now, it simply appends an extension like ".dll" or ".dylib". It
>> doesn't handle versions or anything like that.
>>
>>
>> > On Windows, for example, the conventions are not always followed so
>> closely,
>> > and as a result I keep adding more special cases to my
>> > define-foreign-library clauses when users complain they can't load the
>> > libraries.
>> >
>> > For example, libpng might be png.dll or libpng.dll or libpng12.dll or
>> > libpng12-0.dll or libpng15-15.dll.
>> >
>> > Will I be required to maintain a list of all possible names for the
>> rest of
>> > eternity or is there some better way to manage this situation?
>>
>> Yeah, that sucks. I'm not aware of a better general solution. In some
>> cases, you might get away with searching for "*png*.dll" then loading
>> that using load-foreign-library, but I suppose you need to be careful
>> where you search.
>>
>> HTH,
>>
>> --
>> Luís Oliveira
>> http://kerno.org/~luis/
>>
>>


-- 
Elliott Slaughter

"Don't worry about what anybody else is going to do. The best way to
predict the future is to invent it." - Alan Kay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20140103/83a454e1/attachment.html>


More information about the cffi-devel mailing list