[Ecls-list] using built .a files in C program

Michael Hannemann hannemann at inetmi.com
Mon Mar 31 15:21:01 UTC 2003


 From looking about on the web, I suspect this question has been asked a 
hundred times, but I don't see a hundred answers, so I'll be brave and ask 
myself:

How do I use my statically built library in an external C program?

The goal of the entire operation is to be able to give someone what looks 
like a standard (shared or static) C library so that they don't have to 
worry about there being Lisp inside.

Following the steps in the developer's guide, it seems like I should be 
quite close.  I've been able to copy the stand-alone executable to another 
system and watch it run.  (2.5MB!  Much smaller than ACL or 
Lispworks.)  I've produced a .a file, and I've looked at the temporary .c 
and .h files.  But it seems like there's crucial interface information 
missing; I suspect I could call the munged and re-defined C functions L1 
(L2, &c.), but is there an easier way?

My sample Lisp file is simple:
--
(defun fact (n)
   "A simple factorial function."
   (if (<= n 1)
     1
     (* n (fact (- n 1)))))


(defun fib (n)
   "A lame Fibonacci function."
   (if (<= n 1)
     1
     (+ (fib (- n 1))
        (fib (- n 2)))))
--

I can inspect the temporary header file, the C source, and all that.  But 
I'm not sure how to use it all.  Given this toy example, would it be 
possible for someone to show me how to use this library I've built to call 
these Lisp-defined functions from a C program?


Michael

--
Michael Hannemann
Senior Programmer, I/NET Inc.
hannemann at inetmi.com 





More information about the ecl-devel mailing list