On Sun, Jun 26, 2011 at 8:49 PM, Eric Schulte <firstname.lastname@example.org> wrote:
- What are the contents of main.c in your example above? I assume it is
hand written and not generated by ecl?
- Were you required to write a libfoo.h file to include in main.c or is
that not necessary?
Sorry, I did not copy-paste the content of the C file. Here it goes:
$ ecl -norc
ECL (Embeddable Common-Lisp) 11.1.1
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.
> (require :cmp)
;;; Loading #P"/Users/jjgarcia/lib/ecl-11.1.1/cmp.fas"
> (setf c::*compile-in-constants* t)
> (c:build-shared-library "foo" :lisp-files (list (compile-file "foo" :system-p t :verbose nil)))
;;; Library initialization function is main_dll_FOO
> (ext:system "gcc -o main.exe main.c -L$HOME/lib -L./ -lfoo -lecl")
> (ext:system "./main.exe")
> (ext:system "cat ./foo.lsp")
(defun foo (x)
> (ext:system "cat ./main.c")
extern int main_dll_FOO(int argc, char **argv);
int main(int argc, char **argv)
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.
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)