[Ecls-list] SIMPLE-ERROR: In interpreted code, attempted to call a foreign function but ECL was build without support for that.

Dietrich Bollmann dietrich at formgames.org
Sun May 19 10:40:17 UTC 2013


Hi,

I am trying to use ECL as scripting language for the 3D modelling software
Rhino3D.  The idea is to call a lisp script with something like

  lisp /path/to/the/script.lisp

from the rhino command shell.  In the lisp script I would make use of the
foreign function interface to call Rhino C++ commands for creating and
manipulating Rhino 3D geometry.

Looking at the sources I had the impression that CFFI is the best way to
make the Rhino C++ API accessible from lisp. (Please tell me if this is not
the case and some other method should be used.)  With CFFI it might be even
possible to generate the lisp wrappers automatically using SWIG.

In order to understand CFFI better I decided to start with the FFI examples
in the ecl/examples/ffi/ directory of the ECL source tree.  But when trying
to compile and load the cffi.lsp example using my 64 bit windows compile of
ECL with

  (compile-file "cffi.lsp" :load t)

I get the following error message:

  In interpreted code, attempted to call a foreign function
   #<foreign POINTER-VOID>
  but ECL was build without support for that.

In ecl/src/configure I found the option

  --with-dffi             dynamic foreign function interface
                          (system|included|auto|no, default=AUTO if libffi
                          available)

But I couldn't find anything similar in the windows ecl/msvc/Makefile.

How do I compile the 64 bit version of ECL under Windows with dynamic
foreign function support?

For the case that there is no support for the dynamic foreign function
interface under Windows, how am I supposed to use CFFI in this environment?

I tried to find an answer in the manual as well as searching with google,
but couldn't find any method which would work with the current state of the
ECL sources.

Thanks for your help,

Dietrich


By the way, I found some other problems concerning the foreign function
interface example files:

A. In ecl/examples/ffi/cffi.lsp

1. rather than using

#-(or ming32 windows)
(cffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"
   #-darwin "/usr/lib/libm.so")

The option '-lm' should be used.

2. The line

(cffi:defcfun ("sin" c-sin) :double :double)

should read

(cffi:defcfun ("sin" c-sin) :double '(:double))

3. In

(let ((c-cos (cffi:foreign-funcall "cos" :double 1.0d0 :double)))
   (format t "~%Lisp cos:~t~d~%C cos:~t~d~%Difference:~t~d"
(sin 1.0d0) c-sin (- (sin 1.0d0) c-sin)))

the variable c-cos is defined but c-sin is referred to.

Probably the following was intended:

(let ((c-cos (cffi:foreign-funcall "cos" :double 1.0d0 :double)))
   (format t "~%Lisp cos:~t~d~%C cos:~t~d~%Difference:~t~d"
(cos 1.0d0) c-cos (- (cos 1.0d0) c-cos)))

B. In file ecl/examples/ffi/uffi.lsp

Here again: rather than

#-(or ming32 windows)
(cffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"
   #-darwin "/usr/lib/libm.so")

The option '-lm' should be used
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130519/5b47e368/attachment.html>


More information about the ecl-devel mailing list