gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Interfacing C libraries and lisp.


From: Camm Maguire
Subject: Re: [Gcl-devel] Interfacing C libraries and lisp.
Date: 25 Jun 2002 21:19:59 -0400

Greetings!

disclaimer -- I have not yet had opportunity to try this stuff myself
yet.

I think you can do either.  The lisp wrappers are probably easier, as
you'd likely have to know about the internal gcl stack in writing your
mywrapper.c.  Also, its my understanding that putting a static lib on
the link command line does not ensure all functions are linked into
the final executable.  This is rather ensured by the calls to these
functions present in your compiled lisp or c wrapper objects at link
time.  I can't see any effective difference in using static
vs. dynamic libs, so use dynamic -- saves memory.

Take care,

Conan <address@hidden> writes:

> Ok, this looks good.  Can I use this on a .a or a .so file to load every
> function in a library, and then write lisp functions for each?
> 
> 386-linux.defs
> --------------
> 
>   EXTRAS=/usr/lib/libglut.a
> 
> --------------
> would this work, or would I have to write c code wrappers to each function
> and then have something like this in machines.def.
> 
> 386-linux.defs
> --------------
> 
> LIBS = -lglut
> EXTRAS=mywrapper.o
> 
> --------------
> 
> 
> Conan K Woods
> address@hidden
> 
> On 12 Jun 2002, Camm Maguire wrote:
> 
> > Greetings!  Well, here is what I had seen, from o/littleXlsp.lsp:
> > 
> > ;;This file is included as a demonstration of how to link in low level
> > ;;C code.   It is also useful! [comments by wfs]
> > ;;Author: Mark Ring  (address@hidden)
> > 
> > ;; In the next comment we explain how to link in the file
> > ;; and then a sample usage.
> > 
> > #|
> > If you have si::faslink you may use: 
> > (si::faslink "/public/gcl/lsp/littleXlsp.o" "/public/gcl/o/littleXwin.o 
> > -lX11 -lc")
> > 
> > To avoid using faslink which is much less portable, 
> > when building the gcl image you may add
> > EXTRAS=${ODIR}/littleXwin.o
> > LIBS= -lX -lm -lg
> > to the h/machine.defs, redo the add-defs machine, and remake so that
> > the low level X code will be linked in.
> > Then you may simply
> > (load "/public/gcl/lsp/littleXlsp.o")
> > 
> > ;;Now you may try the following examples: 
> > 
> > .....
> > 
> > Unfortunately, faslink is not yet implemented for Linux/elf, so you'll
> > have to use the second procedure.  Should be very straightforward to
> > get a more portable faslink, but I want to get the (very similar)
> > fasload currently in use ported first.
> > 
> > 
> > 
> > Take care,
> > 
> > 
> > Conan <address@hidden> writes:
> > 
> > > Thanks, that helps quite a bit!  But I do need other libraries, if you
> > > could find out how to add extra libraries it would be a huge help.
> > > 
> > > Conan K Woods
> > > address@hidden
> > > 
> > > On 11 Jun 2002, Camm Maguire wrote:
> > > 
> > > > Greetings!  Maybe try this, with your code in ff.lsp:
> > > > 
> > > > 
> > > > >(compile-file "ff.lsp")
> > > > 
> > > > Compiling ff.lsp.
> > > > End of Pass 1.  
> > > > End of Pass 2.  
> > > > OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
> > > > Finished compiling ff.lsp.
> > > > #p"ff.o"
> > > > 
> > > > >(load "ff.o")
> > > > 
> > > > Loading ff.o
> > > > start address -T 832c234 Finished loading ff.o
> > > > 88
> > > > 
> > > > >(foobar "hello world")
> > > > hello world
> > > > NIL
> > > > 
> > > > -lc is linked into gcl already.  If you need another lib, let me know
> > > >  and I'll dig through the docs -- there is some lisp variable which
> > > >  adds libaries to the command line.
> > > > 
> > > > take care,
> > > > 
> > > > 
> > > > Conan <address@hidden> writes:
> > > > 
> > > > > Hi, I hope this is the correct list to post this on.
> > > > > 
> > > > > I have been having a heck of a time interfacing C and lisp using gcl. 
> > > > >  I
> > > > > am attempting to call a few opengl routines from gcl.  I would be 
> > > > > happy if
> > > > > I could even call printf from gcl, so lets use that as an example. 
> > > > > 
> > > > > (defentry foobar (string) (void "printf"))
> > > > > 
> > > > > The way I understand it, this creates a lisp function that calls the c
> > > > > function printf, which returns void and takes a string argument.
> > > > > 
> > > > > I believe this function has to be compiled somehow, but I am not 
> > > > > entirely
> > > > > clear on this.
> > > > > 
> > > > > The biggest issue I have is how to actually load the library that 
> > > > > contains
> > > > > printf, or whatever other functions I happen to need.
> > > > > 
> > > > > 
> > > > > I am running gcl 2.5 using Debian GNU/Linux.
> > > > > 
> > > > > Anybody have any advice?  I have found hardly any documentation to 
> > > > > help me
> > > > > with this.
> > > > > 
> > > > > Conan K Woods
> > > > > address@hidden
> > > > > 
> > > > > 
> > > > > _______________________________________________
> > > > > Gcl-devel mailing list
> > > > > address@hidden
> > > > > http://mail.gnu.org/mailman/listinfo/gcl-devel
> > > > > 
> > > > > 
> > > > 
> > > > -- 
> > > > Camm Maguire                                            address@hidden
> > > > ==========================================================================
> > > > "The earth is but one country, and mankind its citizens."  --  
> > > > Baha'u'llah
> > > > 
> > > 
> > > 
> > > _______________________________________________
> > > Gcl-devel mailing list
> > > address@hidden
> > > http://mail.gnu.org/mailman/listinfo/gcl-devel
> > > 
> > > 
> > 
> > -- 
> > Camm Maguire                                                address@hidden
> > ==========================================================================
> > "The earth is but one country, and mankind its citizens."  --  Baha'u'llah
> > 
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]