From: Christoph E. <Chr...@gm...> - 2009-02-02 12:55:21
|
Kalyanov Dmitry schrieb: > On Monday 02 February 2009 00:35:45 Christoph Egger wrote: >> Christoph Egger schrieb: >>> Hi! >>> >>> I'm trying to get SWIG running for my lisp environment (currently only >>> testing if it works). I created some very basic .[chi] files and rand >>> swig -cffi in the .i file. However loading the generated .lisp file >>> (load "example.lisp") failed with an hint that there is no siuch thing >>> as CFFI. >>> >>> I'm running this on Debian testing/unstable/experimental, SWIG is in >>> Version 1.3.36 and CFFI is an snapshot from february 2008. >>> >>> Is there anything I do wrong? Anyone had swig+cffi running and could >>> point me to some basic example? >>> >>> Thanks >>> >>> Christoph >> Hi! >> >> Sorry for the noise but I could get this part working with >> (asdf:oos 'asdf:load-op :cffi) >> however loading the swig file still warns me about the function being an >> «Undefined alien» and I can not call the function from within lisp. >> >> Regards >> >> Christoph > > You need to manually add calls to cffi:load-foreign-library (preferably at the > beginning of the file). E.g., add this to .i file: > > %insert("lisphead") %{ > (defpackage :bare-gtk (:use :cl)) > (in-package :bare-gtk) > > (unless (cffi:use-foreign-library "libgtk-x11-2.0.so") > (error "Library libgtk-x11-2.0.so not loaded")) > %} > > If the wrapped library needs some initialization, you should add call to it > after the functions are defined by swig: > > %insert("swiglisp") %{ > (gtk-init (cffi:foreign-alloc :int :initiial-element 0) > (cffi:foreign-alloc :string :initial-contents '("/usr/bin/sbcl"))) > #+sbcl(sb-ext::set-floating-point-modes :traps nil) > %} > Hi! Thank you for this pointer, the basic example does now work. I'll see if I can use it for something more complex now. Regards Christoph -- /"\ ASCII Ribbon : GPG-Key ID: 0x0372275D \ / Campaign : X against HTML : Working for Debian / \ in eMails : http://www.debian.org/ http://www.christoph-egger.org/ |