From: Kenny Tilton
Subject: FFI Newbie Q
Date: 
Message-ID: <3DFC1620.4020600@nyc.rr.com>
I am finally getting my hands dirty with the outside world. Yechh. But, 
hey, now I can put C++ on my resume. Here's the Q:

How do i get to this cool library?

    http://cs.nyu.edu/exact/core/

They rant and rave about Cygwin and supply wonderful make files and 
build instructions for anyone who has used make for about five years, 
but mention in passing "not if you need a shared library".

Sub Q: it's gotta be a dynamic library to get to it from Lisp, yes? That 
at least is my understanding of the ACL doc.

What I think I am looking at is (tediously) building a VC++ DLL project 
outof all the sources, adding all the necessary cruft to prevent C++ 
name mangling and to get the entry points published.

How'm I doin?

-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore

From: Dave Bakhash
Subject: Re: FFI Newbie Q
Date: 
Message-ID: <c297keasxne.fsf@cathedral-seven.mit.edu>
Kenny Tilton <·······@nyc.rr.com> writes:

> How do i get to this cool library?
> 
>     http://cs.nyu.edu/exact/core/

IIRC, you're using ACL.  They have excellent FFI docs which include how
to compile shared objects on the various different platforms.

One thing that might help is if this thing already generates a static
library (.a in most Unix).  If so, it should't be too big of a push to
output the dynamic library.

> Sub Q: it's gotta be a dynamic library to get to it from Lisp, yes? 
> That at least is my understanding of the ACL doc.

yes.  FFI can load dynamic libraries only, AFAIK.

> What I think I am looking at is (tediously) building a VC++ DLL
> project outof all the sources, adding all the necessary cruft to
> prevent C++ name mangling and to get the entry points published.

again, check out the appendix in ACL's FFI docs:

$ACL_HOME/doc/foreign-functions.htm#ff-on-windows-1

The first section (A.1) is "making a .dll", and gives detailed
instructions.

dave
From: Russell McManus
Subject: Re: FFI Newbie Q
Date: 
Message-ID: <877keanlye.fsf@thelonious.dyndns.org>
Kenny Tilton <·······@nyc.rr.com> writes:

> What I think I am looking at is (tediously) building a VC++ DLL
> project outof all the sources, adding all the necessary cruft to
> prevent C++ name mangling and to get the entry points published.

I don't think that it's possible to stop name mangling.  Generally, if
you want to access a C++ library from a lisp FFI you have to write
wrapper functions with C linkage to provide entry points into the
library.  But this may be a case where I don't know about some VC++
feature.

-russ
From: Kaz Kylheku
Subject: Re: FFI Newbie Q
Date: 
Message-ID: <cf333042.0212161148.28982ed8@posting.google.com>
Kenny Tilton <·······@nyc.rr.com> wrote in message news:<················@nyc.rr.com>...
 
> What I think I am looking at is (tediously) building a VC++ DLL project 
> outof all the sources, adding all the necessary cruft to prevent C++ 
> name mangling and to get the entry points published.

C++ name mangling is an implementation feature; it's a hack needed to
implement the C++ type-safe linkage and function overloading on top of
old-fashioned linkers.

C++ has features for compatibility with other languages (think of it
as a FFI). There is something called a linkage specification, whose
syntax is roughly:

   extern "lang" <declaration> 

or

   extern "lang" { <declarations> ... }

Where the only standard-defined "lang" is "C". Functions that are
defined extern "C" have C compatible linkage. This means that there is
no name mangling.

Use extern "C" to define functions that are callable from C modules,
or to declare outside C functions so they can be called from C++.

Often there is a need to write a header file that defines an interface
that can be used by both C and C++. In that case, use #ifdef's to
conditionally insert the extern "C" dance:

   #ifdef __cplusplus
   extern "C" {
   #endif
   /* declarations go here */
   #ifdef __cplusplus
   } 
   #ndif

A good strategy for using a C++ library from a Lisp is to write a
compatibility layer made up of extern "C" functions, and target those.
Those functions are still C++ and can do normal C++ things like
instantiate objects, and invoke virtual functions on them, etc.
From: Kenny Tilton
Subject: Re: FFI Newbie Q
Date: 
Message-ID: <3DFE3957.1070204@nyc.rr.com>
OK, everyone, thx for the input. Now I grok all these cl-<cool library> 
projects. It's easy, but it's a lot of it. Oh, yummy, I get to put C++ 
on my resume!

:)



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore