Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

linking lisp to C/C++

54 views
Skip to first unread message

Zachary Turner

unread,
Nov 23, 1998, 3:00:00 AM11/23/98
to
can LISP functions be linked to C/C++?

willi

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
NO, you can only link c++ funktions to lisp not vice versa

So long willi

Zachary Turner schrieb in Nachricht <73c99f$nl6$1...@uuneo.neosoft.com>...

Marco Antoniotti

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to

"willi" <wi...@willi.com> writes:

> NO, you can only link c++ funktions to lisp not vice versa
>

AFAIK not even that. I think most languages support linking of C
objects, not C++. The only way to link in the C++ is to go through a C
layer, pretty much the way it is done in JNI.

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - (0)6 - 68 10 03 17, fax. +39 - (0)6 - 68 80 79 26
http://www.parades.rm.cnr.it

David Thornley

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
In article <73c99f$nl6$1...@uuneo.neosoft.com>,

Zachary Turner <ztu...@elsitech.com> wrote:
>can LISP functions be linked to C/C++?
>
Um, what platform are we talking about? What Lisp implementation?
What C or C++ implementation?

On my Macintosh, with Macintosh Common Lisp and Metrowerks Codewarrior,
it's easy (provided you do not care about supporting old Macs.).
You simply compile the C and C++ as a shared library, provide a
pointer to the library, define a few entry points in Lisp, and
you're off. It is necessary that the main program be in Lisp
and the C or C++ in a shared library.

--
David H. Thornley | These opinions are mine. I
da...@thornley.net | do give them freely to those
http://www.thornley.net/~thornley/david/ | who run too slowly. O-

Steve Jacobson

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to

Zachary Turner wrote in message <73c99f$nl6$1...@uuneo.neosoft.com>...

>can LISP functions be linked to C/C++?
>
>

You can do it with Allegro Common Lisp 5.0

Pierre Mai

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
"willi" <wi...@willi.com> writes:

> NO, you can only link c++ funktions to lisp not vice versa
>

> So long willi
>
> Zachary Turner schrieb in Nachricht <73c99f$nl6$1...@uuneo.neosoft.com>...


> >can LISP functions be linked to C/C++?

There is at least one implementation, where this is wrong: Eclipse
Common Lisp compiles Common Lisp functions to C functions, which can be
linked against other C/C++ code. Eclipse is a very reasonably priced
commercial CL implementation available for Win32 and Linux, IIRC. Take
a look at http://www.elwood.com/eclipse/ for more information.

IIRC there is also EcoLisp, which does similar things, but I don't
know any details...

Regs, Pierre.

--
Pierre Mai <pm...@acm.org> http://home.pages.de/~trillian/
"One smaller motivation which, in part, stems from altruism is Microsoft-
bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]

Howard R. Stearns

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
Zachary Turner wrote:
>
> can LISP functions be linked to C/C++?

See http://www.elwood.com/eclipse-info, and in particular, the paper
link near the top.

More generally, see http://www.elwood.com/alu/table/combine.htm

Zachary Turner

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
>Um, what platform are we talking about? What Lisp implementation?
>What C or C++ implementation?
>
>On my Macintosh, with Macintosh Common Lisp and Metrowerks Codewarrior,
>it's easy (provided you do not care about supporting old Macs.).
>You simply compile the C and C++ as a shared library, provide a
>pointer to the library, define a few entry points in Lisp, and
>you're off. It is necessary that the main program be in Lisp
>and the C or C++ in a shared library.


No No. l I want the other way around. I want to know if I can write code
in LISP and link it into a program i've written in C or C++. It shouldn't
matter what platform or implementation of anything I'm on, unless there are
only certain LISP compilers that can do this. C functions have a standard
calling convention. It's a matter of whether or not the LISP compiler can
compile it to a C function. All it really has to do is put the underscore
in front of a function name (of course i know nothing about LISP or how it
handles functions. the whole reason i started the thread is because i want
to know what i can and can't do with LISP, seeing as how i'm about to start
getting heavily into AI programming.) But just to clarify i'm using Windows
NT 4.0 and Visual Studio 6.0. So i want to write some functions in LISP,
compile them into a .DLL (using Allegro CL 5.0 more than likely) and call
one of these .DLL functions from my C++ program. Can this be done?

Christopher Browne

unread,
Nov 25, 1998, 3:00:00 AM11/25/98
to

Definitely somewhat more problematic, as Lisp programs have some
"expectations" as to their access to memory, and management thereof,
particularly in the context of garbage-collectible objects.

For some insight, you might look at the model used by Guile, a SCM
variant, for how it may be embedded into C applications, you might want
to take a look at:

http://nis-www.lanl.gov/~rosalia/gnudl-doc/learn_libguile_toc.html
http://www.cygnus.com/library/ctr/guile.html
http://www.gnu.org/software/guile/guile.html

The basic point of the exercise is that any variables that you want to
pull into the C/C++ side from the "Lisp side of the world" have to be
specially accessed; variables that you want to push from the "C/C++
side" to the "Lisp side" must similarly be carefully defined so that
garbage collection sees them in an appropriate light.

--
[In response to deprecations of the use of <linux/*.h>] ...I prefer code
that only compiles on Linux... I really don't care to help other
operating systems grow. -- Albert D. Cahalan <acah...@saturn.cs.uml.edu>
cbbr...@hex.net- <http://www.hex.net/~cbbrowne/lsf.html>

Bruce Tobin

unread,
Dec 5, 1998, 3:00:00 AM12/5/98
to
Zachary Turner wrote:

> [..] But just to clarify i'm using Windows


> NT 4.0 and Visual Studio 6.0. So i want to write some functions in LISP,
> compile them into a .DLL (using Allegro CL 5.0 more than likely) and call
> one of these .DLL functions from my C++ program. Can this be done?

Yes. ACL 5 can compile into DLL format. ACL 5 has just about everything that a
lot of folks in this newsgroup have been clamoring for; I strongly recommend
that anyone who's thinking about doing Windows development give it a look.


0 new messages