<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 20, 2013 at 4:15 AM, Dietrich Bollmann <span dir="ltr"><<a href="mailto:dietrich@formgames.org" target="_blank">dietrich@formgames.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><div><br></div></div><div><font face="arial, sans-serif">I tried to do so - but for some reason I never get it work...</font></div>
</blockquote></div><br>The CFFI model is simply too rigid: they assume that libraries can be loaded at run time, always. Instead ECL supports also a model in which libraries are linked with the compiled code, being available that way. I fear there is no way to work around this but using ECL's own FFI mingled with CFFI</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">> (ql:quickload :cffi)<br></div><div class="gmail_extra">To load "cffi":</div><div class="gmail_extra"> Load 1 ASDF system:</div>
<div class="gmail_extra"> cffi</div><div class="gmail_extra">; Loading "cffi"</div><div class="gmail_extra"><br></div><div class="gmail_extra">(:CFFI)</div><div class="gmail_extra">> (compile-file "foo.lsp" :load t)</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">;;;</div><div class="gmail_extra">;;; Compiling foo.lsp.</div><div class="gmail_extra">;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0</div><div class="gmail_extra">
;;;</div><div class="gmail_extra">;;; Compiling (DEFCFUN (MYCOS "cos") ...).</div><div class="gmail_extra">;;; End of Pass 1.</div><div class="gmail_extra">;;; Emitting code for MYCOS.</div><div class="gmail_extra">
;;; Finished compiling foo.lsp.</div><div class="gmail_extra">;;;</div><div class="gmail_extra">;;; Loading "/Users/jjgarcia/foo.fas"</div><div class="gmail_extra">C: cos(3.2000000000000001777d+0) = -0.9982947757947531 </div>
<div class="gmail_extra">Lisp: cos(3.2000000000000001777d+0) = -0.9982947757947531 </div><div class="gmail_extra">#P"/Users/jjgarcia/foo.fas"</div><div class="gmail_extra">NIL</div><div class="gmail_extra">NIL</div>
<div><br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">----</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">;;; Nothing special about the "CFFI-USER" package. We're just</div>
<div class="gmail_extra">;;; using it as a substitute for your own CL package.</div><div class="gmail_extra">(defpackage :cffi-user</div><div class="gmail_extra"> (:use :common-lisp :cffi))</div><div class="gmail_extra">
<br></div><div class="gmail_extra">(in-package :cffi-user)</div><div class="gmail_extra"><br></div><div class="gmail_extra">#-ecl</div><div class="gmail_extra">(progn</div><div class="gmail_extra"> (define-foreign-library libm</div>
<div class="gmail_extra"> (:unix (:or "libm.so" "libm.dylib"))</div><div class="gmail_extra"> (t (:default "libm")))</div><div class="gmail_extra"> (use-foreign-library libm))</div>
<div class="gmail_extra">
<br></div><div class="gmail_extra">#+ecl</div><div class="gmail_extra">(ffi:load-foreign-library "/usr/lib/libm.dylib" :system-library nil)</div><div class="gmail_extra"><br></div><div class="gmail_extra">;;; Initialize libcurl with FLAGS.</div>
<div class="gmail_extra">(defcfun (mycos "cos") :double (value :double))</div><div class="gmail_extra"><br></div><div class="gmail_extra">(format t "C: cos(~e) = ~g~%" 3.2d0 (mycos 3.2d0))</div><div class="gmail_extra">
(format t "Lisp: cos(~e) = ~g~%" 3.2d0 (cos 3.2d0))</div><div><br></div><br clear="all"><div><br></div>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a>
</div></div>