From: David Meysman
Subject: Making an executable for GCL
Date: 
Message-ID: <3be96716$0$79554$53a6e767@news.tcinternet.net>
Hello Lisp Users,

I have just started to use GCL, and just joined this group.

I noticed using (compile-file "filename") that an object file is created
(i.e., a '.o' file).

I am confused now how to proceed to make an executable.  Does one now create
a normal 'C' file with a main( ) function, and then link in the Lisp object
file?  If so, how does one actually start the Lisp part of the program
(i.e., how does one call the Lisp side of things from within the main( )
function)?

Or, is there more magic to this?

Ideally, what would help me is an Hello World example plus makefile (showing
libraries and all).  I know this is asking for a lot, though.

Dave Meysman

From: Gabe Garza
Subject: Re: Making an executable for GCL
Date: 
Message-ID: <8zdijvxj.fsf@kynopolis.org>
"David Meysman" <········@tcinternet.net> writes:

> Hello Lisp Users,
> 
> I have just started to use GCL, and just joined this group.
> 
> I am confused now how to proceed to make an executable.  Does one now create
> a normal 'C' file with a main( ) function, and then link in the Lisp object

   This is pretty easy with GCL, and, AFAIK, not possible with the other 
free CL's.  Here's a little "Hello World" tutorial:

   1.) Make a file called "hello.lisp" that contains the following:

START
(defun si:top-level ()
  (write-line "Hello, World!"))
END

   2.) Start up GCL, then compile the lisp file, load the object file, and
save the image--the image is your executable:

[root]~/gcl$ gcl
GCL (GNU Common Lisp)  Version(2.3) Thu Oct 25 14:59:01 PDT 2001
Licensed under GNU Library General Public License
Contains Enhancements by W. Schelter

>(compile-file "hello.lisp")

Compiling hello.lisp.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling hello.lisp.
#"hello.o"

>(load "hello.o")

Loading hello.o
start address -T 82a4d44 Finished loading hello.o
104

>(si:save-system "hello")
[root]~/gcl$ ./hello
Hello, World!
[root]~/gcl$ 


I'm not sure how familiar you are with Common Lisp development, but
most free Common Lisps don't really support this because this isn't
how development is typically done in Common Lisp.  Instead of a C'ish
write-compile-run-coredump-debug-repeat cycle, you instead run a Lisp
process and use an emacs-like editor to incrementally build your
system.  If you're new to Lisp, I'd advise you to look into this
because it's one of the most attractive features of the language.

If you're not new to Lisp, and are just trying to deploy an
application, then nevermind. :)

Gabe Garza
From: Tomas Hlavaty
Subject: Re: Making an executable for GCL
Date: 
Message-ID: <3BEA94E9.9496C302@labe.felk.cvut.cz>
> > I am confused now how to proceed to make an executable.  Does one now create
> > a normal 'C' file with a main( ) function, and then link in the Lisp object
> 
>    This is pretty easy with GCL, and, AFAIK, not possible with the other
> free CL's.

Is it also easy (or possible) to call C functions from GCL? What should
I do for that? Write a C wraper...? Is there any description how to
import C functions to GCL?

Thanks

Tomas Hlavaty
From: Marco Antoniotti
Subject: Re: Making an executable for GCL
Date: 
Message-ID: <y6cy9lh8ev9.fsf@octagon.mrl.nyu.edu>
Tomas Hlavaty <·······@labe.felk.cvut.cz> writes:

> > > I am confused now how to proceed to make an executable.  Does one now create
> > > a normal 'C' file with a main( ) function, and then link in the Lisp object
> > 
> >    This is pretty easy with GCL, and, AFAIK, not possible with the other
> > free CL's.
> 
> Is it also easy (or possible) to call C functions from GCL? What should
> I do for that? Write a C wraper...? Is there any description how to
> import C functions to GCL?

You can "import" C function in every CL implementation I know of.  It
is the way you do it that is different.

GCL has a few niceties in this respect, since you can directly write C
code as strings, embedded in your CL code.  Apart from that,  it is
just the same in other implementations.

I should mention that I like what Cparse
<http://www.bricoworks.com/~moore/cparse/index.html> does for CMUCL.

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Gabe Garza
Subject: Re: Making an executable for GCL
Date: 
Message-ID: <4ro5ji7t.fsf@kynopolis.org>
Tomas Hlavaty <·······@labe.felk.cvut.cz> writes:

> Is it also easy (or possible) to call C functions from GCL? What
> should I do for that? Write a C wraper...? Is there any description
> how to import C functions to GCL?

Indeed!  In GCL's manual, of all places. ;) Look in the section "GCL
Specific," specifically the entries DEFCFUN and DEFENTRY, and also the
section "System Definitions," specifically the entry for FASLINK.
Note that it may not be *that* easy with GCL, because--if the docs are
current--if you don't have a BSD box you'll need to link GCL with the
libraries you wish to call at (GCL's) build time.

If you're new to Lisp, I'd strongly recommend using one of the other
free Common Lisps.  They too have foreign function interfaces, and
they're modern implementations.  GCL implements a version of Common
Lisp that is a precursor to ANSI Common Lisp, thus it lacks a lot of
niceties, such as the LOOP language and CLOS, to name two.  If you're
not new to Common Lisp, then once again: nevermind...

Gabe Garza
From: Tomas Hlavaty
Subject: Re: Making an executable for GCL
Date: 
Message-ID: <3BEBA100.6E646C6F@labe.felk.cvut.cz>
> If you're new to Lisp, I'd strongly recommend using one of the other
> free Common Lisps.

Yes, I'm new to Lisp. Thanks for your tip.

> I should mention that I like what Cparse
> <http://www.bricoworks.com/~moore/cparse/index.html> does for CMUCL.

That is I was looking for.

Thank you.

Tomas Hlavaty
From: Alexey Dejneka
Subject: Re: Making an executable for GCL
Date: 
Message-ID: <m3n11yxyr0.fsf@comail.ru>
Hello,

"David Meysman" <········@tcinternet.net> writes:
> I noticed using (compile-file "filename") that an object file is created
> (i.e., a '.o' file).
> 
> I am confused now how to proceed to make an executable.

Sorry for silly question, but you have not asked whether is it
possible at all. So, are you sure you really want to make an
executable? You can simply enter (load "filename") and all your
definitions will be loaded into GCL.

---hello.lisp---
(print "hello!")
----------------

This file prints "hello!" during loading.

---hello-fun.lisp---
(defun hello (name)
  (format t "Hello, ~A!~%" name))
--------------------

In this file HELLO function is defined.

---session---
> (compile-file "/tmp/hello.lisp")
Compiling /tmp/hello.lisp.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling /tmp/hello.lisp.
#"/tmp/hello.o"

> (load "/tmp/hello")
Loading /tmp/hello.o

"hello!" start address -T 82bf210 
Finished loading /tmp/hello.o
28

> (load "/tmp/hello-fun")
Loading /tmp/hello-fun.o
start address -T 82bf2c0 Finished loading /tmp/hello-fun.o
120

> (hello "Alexey")
Hello, Alexey!
NIL
-------------


Regards,
Alexey Dejneka

-- 
(loop with nil = t do ...)