[gambit-list] Compiling Gambit-C to dll and loading into .NET

James Long longster at gmail.com
Tue Feb 13 17:31:57 EST 2007

On 2/13/07, Marc Feeley <feeley at iro.umontreal.ca> wrote:
> Hash: SHA1
> On 13-Feb-07, at 1:18 AM, James Long wrote:
> > There's got to be something I'm missing, has anyone else gotten
> > this to work?  Or does anyone see anything wrong with how I'm
> > compiling the dll (the loading part is relatively simple and I
> > doubt the problem is in there)?
> Yes.  What is missing is the *initialization* of the Gambit-C runtime
> system (all the tables used by Gambit-C, the memory manager, the I/O
> subsystem, etc).  This is done with a call to ___setup(...).  The
> initialization must happen before the first call to any function your
> Scheme DLL is exporting.  The best approach is probably to call
> ___setup(...) when the code is loaded (i.e. the call ___setup(...)
> should be in the DllMain function).  It is good style to call
> ___cleanup() when the DLL is unloaded.
> I've copied below the code that works for me.  I'm using MinGW.
> Small variations may be needed to the makefile for Cygwin and
> Microsoft's compiler.
> Let me know if this works with .NET .
> Marc
Thanks, that worked great!  Ah the benefits of compiling to C.  brilliant.

Could you explain the LINKER macro, though?  Or is there any documentation
about this setup anywhere?  I found a couple other emails about this but
none of them really explained it.  What is LINKER (defined as ____20_dll__
in mine, which supposedly works) supposed to represent?

Also, what exactly does the D___DYNAMIC flag to gcc do, out of curiousity?
I'm assuming it does things like tell gambit not to generate a main
function, and possibly specify calling conventions and exporting
attributes.  Seems like it's mainly used to generate a dynamic library to be
loaded by Gambit, though I think I need it in this situation as well.
Gambit could use the same flag to generate that DllMain function, but I
guess the focus is on a library for use with Gambit.

James L
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20070213/33857879/attachment.htm>

More information about the Gambit-list mailing list