I am attaching a patch for CFFI that allows ECL to build code that does not use dlopen() but rather uses the function symbols as they are know to the C compiler. This is best explained in the code comments, which I reproduce below, and in the example.<div>
<br></div><div>The patched CFFI is available at my github account</div><div><a href="https://github.com/juanjosegarciaripoll/cffi">https://github.com/juanjosegarciaripoll/cffi</a><br><div><br></div><div>This is how the example is used<br clear="all">
<div><br></div><div><div>bash-3.2$ ecl -norc</div><div>ECL (Embeddable Common-Lisp) 12.7.1 (git:e95fa190ccab10a5dcca791658d7d3ff24a77240)</div><div>Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya</div><div>Copyright (C) 1993 Giuseppe Attardi</div>
<div>Copyright (C) 2000 Juan J. Garcia-Ripoll</div><div>ECL is free software, and you are welcome to redistribute it</div><div>under certain conditions; see file 'Copyright' for details.</div><div>Type :h for Help. </div>
<div>Top level in: #<process TOP-LEVEL>.</div><div>> (load "build")</div><div>[...]</div><div>To load "cffi":</div><div> Load 1 ASDF system:</div><div> cffi</div><div>; Loading "cffi"</div>
<div><br></div><div>;;;</div><div>;;; Compiling cffi-test.lisp.</div><div>;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0</div><div>;;;</div><div>;;; Compiling (CFFI:DEFCFUN ("sin" C-SINE) ...).</div><div>
;;; Compiling (DEFUN FF-C-SINE ...).</div><div>;;; End of Pass 1.</div><div>;;; Emitting code for C-SINE.</div><div>;;; Emitting code for FF-C-SINE.</div><div>;;; Finished compiling cffi-test.lisp.</div><div>;;;</div><div>
;;; Loading "/Users/jjgarcia/build/cffi-static/cffi-test.fas"</div><div><br></div><div> sin(pi) = 1.22464679914735320720000000000000d-16</div><div>#P"/Users/jjgarcia/build/cffi-static/build.lisp"</div>
</div><div><br></div><div>This is the self-explanatory comment</div><div><br></div><div><div>;;;</div><div>;;; ECL allows many ways of calling a foreign function, and also many</div><div>;;; ways of finding the pointer associated to a function name. They</div>
<div>;;; depend on whether the FFI relies on libffi or on the C/C++ compiler,</div><div>;;; and whether they use the shared library loader to locate symbols</div><div>;;; or they are linked by the linker.</div><div>;;;</div>
<div>;;; :DFFI</div><div>;;;</div><div>;;; ECL uses libffi to call foreign functions. The only way to find out</div><div>;;; foreign symbols is by loading shared libraries and using dlopen()</div><div>;;; or similar.</div>
<div>;;;</div><div>;;; :DLOPEN</div><div>;;;</div><div>;;; ECL compiles FFI code as C/C++ statements. The names are resolved</div><div>;;; at run time by the shared library loader every time the function</div><div>;;; is called</div>
<div>;;;</div><div>;;; :C/C++</div><div>;;;</div><div>;;; ECL compiles FFI code as C/C++ statements, but the name resolution</div><div>;;; happens at link time. In this case you have to tell the ECL</div><div>;;; compiler which are the right ld-flags (c:*ld-flags*) to link in</div>
<div>;;; the library.</div><div>;;;</div><div>(defvar *cffi-ecl-method*</div><div> #+dffi :dffi</div><div> #+(and dlopen (not dffi)) :dlopen</div><div> #-(or dffi dlopen) :c/c++</div><div> "The type of code that CFFI generates for ECL: :DFFI when using the</div>
<div>dynamical foreign function interface; :DLOPEN when using C code and</div><div>dynamical references to symbols; :C/C++ for C/C++ code with static</div><div>references to symbols.")</div></div><div><br></div><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><br>
</div></div>