On Sun, Jun 26, 2011 at 8:49 PM, Eric Schulte <span dir="ltr"><<a href="mailto:schulte.eric@gmail.com">schulte.eric@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
- What are the contents of main.c in your example above? I assume it is<br>
hand written and not generated by ecl?<br>
<br>
- Were you required to write a libfoo.h file to include in main.c or is<br>
that not necessary?</blockquote></div><br>Sorry, I did not copy-paste the content of the C file. Here it goes:<br><br>$ ecl -norc<br>ECL (Embeddable Common-Lisp) 11.1.1<br>Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya<br>
Copyright (C) 1993 Giuseppe Attardi<br>Copyright (C) 2000 Juan J. Garcia-Ripoll<br>ECL is free software, and you are welcome to redistribute it<br>under certain conditions; see file 'Copyright' for details.<br>Type :h for Help. <br>
Top level.<br>> (require :cmp)<br><br>;;; Loading #P"/Users/jjgarcia/lib/ecl-11.1.1/cmp.fas"<br>("CMP")<br><br>> (setf c::*compile-in-constants* t)<br><br>T<br>> (c:build-shared-library "foo" :lisp-files (list (compile-file "foo" :system-p t :verbose nil)))<br>
;;; [...]<br>;;; Note:<br>;;; Library initialization function is main_dll_FOO<br>;;; [...]<br>#P"libfoo.dylib"<br>> (ext:system "gcc -o main.exe main.c -L$HOME/lib -L./ -lfoo -lecl")<br><br>0<br>
> (ext:system "./main.exe")<br>
<br>HOLA <br>0<br>> (ext:system "cat ./foo.lsp")<br>(defun foo (x)<br> (print x))<br><br>(foo 'hola)<br><br>0<br>> (ext:system "cat ./main.c")<br>extern int main_dll_FOO(int argc, char **argv);<br>
<br>int main(int argc, char **argv)<br>{<br> main_dll_FOO(argc, argv);<br> si_exit(0);<br>}<br><br>0<br><br>Notice that the name of the function was announced by ECL in a comment after C:BUILD-SHARED-LIBRARY. The declaration does not need to live in a *.h file, it may be in the same compiled file.<br>
<br>Juanjo<br clear="all"><br>-- <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>