<div dir="ltr">Hi,<div><br></div><div>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</div><div><br></div><div>  lisp /path/to/the/script.lisp</div>
<div><br></div><div>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.</div><div><br></div><div>
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.</div>
<div><br></div><div>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<div style>
<br></div><div style><div>  (compile-file "cffi.lsp" :load t)</div><div><br></div></div><div style>I get the following error message:</div><div style><br></div><div style><div>  In interpreted code, attempted to call a foreign function</div>
<div>   #<foreign POINTER-VOID></div><div>  but ECL was build without support for that.</div><div><br></div><div>In ecl/src/configure I found the option <br></div><div><br></div><div><div>  --with-dffi             dynamic foreign function interface</div>
<div>                          (system|included|auto|no, default=AUTO if libffi</div><div>                          available)</div></div><div><br></div><div style>But I couldn't find anything similar in the windows ecl/msvc/Makefile.</div>
<div style><br></div><div style>How do I compile the 64 bit version of ECL under Windows with dynamic foreign function support?</div><div style><br></div><div style>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?</div>
<div style><br></div><div style>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.</div><div style><br></div>
<div style>Thanks for your help,</div><div style><br></div><div style>Dietrich</div><div style><br></div><div style><br></div><div style>By the way, I found some other problems concerning the foreign function interface example files:</div>
<div style><br></div><div style>A. In ecl/examples/ffi/cffi.lsp<br></div><div style><br></div><div style>1. rather than using </div><div style><br></div><div style><div>#-(or ming32 windows)</div><div>(cffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"</div>
<div><span class="" style="white-space:pre">                    </span>   #-darwin "/usr/lib/libm.so")</div><div><br></div><div>The option '-lm' should be used.<br></div><div><br></div><div style>2. The line</div><div style>
<br></div><div style><div>(cffi:defcfun ("sin" c-sin) :double :double)</div><div><br></div><div style>should read </div><div style><br></div><div style>(cffi:defcfun ("sin" c-sin) :double '(:double))<br>
</div><div style><br></div><div style>3. In</div><div style><br></div><div style><div>(let ((c-cos (cffi:foreign-funcall "cos" :double 1.0d0 :double)))</div><div>   (format t "~%Lisp cos:~t~d~%C cos:~t~d~%Difference:~t~d"</div>
<div><span class="" style="white-space:pre">    </span>(sin 1.0d0) c-sin (- (sin 1.0d0) c-sin)))</div><div><br></div><div style>the variable c-cos is defined but c-sin is referred to.</div><div style><br></div><div style>Probably the following was intended:</div>
<div style><br></div><div style><div>(let ((c-cos (cffi:foreign-funcall "cos" :double 1.0d0 :double)))</div><div>   (format t "~%Lisp cos:~t~d~%C cos:~t~d~%Difference:~t~d"</div><div><span class="" style="white-space:pre">    </span>(cos 1.0d0) c-cos (- (cos 1.0d0) c-cos)))</div>
<div><br></div></div><div>B. In file ecl/examples/ffi/uffi.lsp</div><div><br></div><div><div>Here again: rather than</div><div><br></div><div><div>#-(or ming32 windows)</div><div>(cffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"</div>
<div><span class="" style="white-space:pre">                    </span>   #-darwin "/usr/lib/libm.so")</div><div><br></div><div>The option '-lm' should be used<br></div></div></div><div><br></div></div></div></div><div style>
<br></div><div><br></div></div></div></div>