On Sun, Jun 26, 2011 at 8:49 PM, Eric Schulte <schulte.e...@gmail.com>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.
Top level.
> (require :cmp)

;;; Loading #P"/Users/jjgarcia/lib/ecl-11.1.1/cmp.fas"
("CMP")

> (setf c::*compile-in-constants* t)

T
> (c:build-shared-library "foo" :lisp-files (list (compile-file "foo"
:system-p t :verbose nil)))
;;; [...]
;;; Note:
;;;   Library initialization function is main_dll_FOO
;;; [...]
#P"libfoo.dylib"
> (ext:system "gcc -o main.exe main.c -L$HOME/lib -L./ -lfoo -lecl")

0
> (ext:system "./main.exe")

HOLA
0
> (ext:system "cat ./foo.lsp")
(defun foo (x)
 (print x))

(foo 'hola)

0
> (ext:system "cat ./main.c")
extern int main_dll_FOO(int argc, char **argv);

int main(int argc, char **argv)
{
  main_dll_FOO(argc, argv);
  si_exit(0);
}

0

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.

Juanjo

-- 
Instituto de FĂ­sica Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to