[Ecls-list] Getting "hello world" going
Mark Carter
mcturra2000 at yahoo.co.uk
Fri Aug 24 12:07:01 UTC 2007
Getting closer. I now have ecl1.lisp:
(defun say-hello ()
(format *terminal-io* "hello world"))
which I compile using
ecl -compile ecl1.lisp
I also have ecl2.c:
#include <ecl/ecl.h>
main()
{
cl_object form, result;
char* my_args[ 1 ] = { "ecl" };
const char *lisp_code = "(progn (load \"ec1.fas\") (say-hello))";
cl_boot( 1, my_args );
form = c_string_to_object(lisp_code);
result = si_safe_eval(3,form, Cnil, OBJNULL );
cl_shutdown();
}
which I compile using:
gcc -lelc ecl2.c
When I run a.out, though, it doesn't print "hello world" as I would expect; although it now doesn't crash. I'm using Linux. Should I be doing things in a different way?
----- Original Message ----
From: Goffioul Michael <goffioul at imec.be>
To: Mark Carter <mcturra2000 at yahoo.co.uk>; ecls-list at lists.sourceforge.net
Sent: Friday, 24 August, 2007 11:51:54 AM
Subject: RE: [Ecls-list] Getting "hello world" going
DIV {
MARGIN:0px;}
You have to initialize ECL engine before calling ECL
functions. Use
cl_boot for this.
Michael.
From: ecls-list-bounces at lists.sourceforge.net
[mailto:ecls-list-bounces at lists.sourceforge.net] On Behalf Of Mark
Carter
Sent: Friday 24 August 2007 11:50
To: Mark Carter;
ecls-list at lists.sourceforge.net
Subject: Re: [Ecls-list] Getting
"hello world" going
I
know I'm being a bit vague here, but it's not really happening for me. .
Suppose, instead, I have hello.c:
#include
<ecl/ecl.h>
main()
{
cl_object form,
result;
form = c_string_to_object("(+ 1 2)");
result =
si_safe_eval(4,form, Cnil, OBJNULL );
}
and I compile it
using
gcc -lecl hello.c
When I
type
./a.out
I get
Segmentation
Fault
-----
Original Message ----
From: Mark Carter
<mcturra2000 at yahoo.co.uk>
To:
ecls-list at lists.sourceforge.net
Sent: Friday, 24 August, 2007 12:07:18
AM
Subject: [Ecls-list] Getting "hello world" going
I am trying to call Lisp code from C.
Suppose I have the Lisp file
sayhello.lisp:
(defun say-hello ()
(print "hello
world"))
and a C file
hello.c:
main()
{
say_hello(); /* ??
*/
}
How do I compile everything into a program so that it all
works?
Yahoo! Answers - Get better answers from someone who knows. Try it now.
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy
and free. Do
it now...
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20070824/830b44ae/attachment.html>
More information about the ecl-devel
mailing list