[Ecls-list] SIMPLE-ERROR: In interpreted code, attempted to call a foreign function but ECL was build without support for that.
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at gmail.com
Tue May 21 09:13:50 UTC 2013
On Mon, May 20, 2013 at 4:15 AM, Dietrich Bollmann
<dietrich at formgames.org>wrote:
> I tried to do so - but for some reason I never get it work...
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
> (ql:quickload :cffi)
To load "cffi":
Load 1 ASDF system:
; Loading "cffi"
> (compile-file "foo.lsp" :load t)
;;; Compiling foo.lsp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
;;; Compiling (DEFCFUN (MYCOS "cos") ...).
;;; End of Pass 1.
;;; Emitting code for MYCOS.
;;; Finished compiling foo.lsp.
;;; Loading "/Users/jjgarcia/foo.fas"
C: cos(3.2000000000000001777d+0) = -0.9982947757947531
Lisp: cos(3.2000000000000001777d+0) = -0.9982947757947531
;;; Nothing special about the "CFFI-USER" package. We're just
;;; using it as a substitute for your own CL package.
(:use :common-lisp :cffi))
(:unix (:or "libm.so" "libm.dylib"))
(t (:default "libm")))
(ffi:load-foreign-library "/usr/lib/libm.dylib" :system-library nil)
;;; Initialize libcurl with FLAGS.
(defcfun (mycos "cos") :double (value :double))
(format t "C: cos(~e) = ~g~%" 3.2d0 (mycos 3.2d0))
(format t "Lisp: cos(~e) = ~g~%" 3.2d0 (cos 3.2d0))
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ecl-devel