Hey guys,<br><br>I'm attempting to write a .NET stub for a Scheme program.  I want to compile the gambit scheme code down to C and then compile it into a Windows DLL.  Then I can load this DLL into .NET and write an interface for it.
<br><br>I've accomplished all of this (with a simple hello world program), but the .NET app always crashes.  The first time I tried it, I used cygwin and compiled this scheme code:<br><br>* (c-define (helloworld) () void "helloworld" ""
<br>*            (display "Hello"))<br><br>with gsc like this:<br><br>* gsc -link func.scm<br><br>and then compiled the corresponding c files with gcc like so:<br><br>* gcc -Iinclude -shared -D___DYNAMIC func*.c -o 
func.dll -lgambc -lwsock32 -lws2_32<br><br>which compiled fine.  That should produce a Windows DLL, right?  I'm a little skeptical at that part because I've never used gcc to produce a windows dll before.  But read on before you think that's the problem.
<br><br>As the final step I created the .NET interface with the following few lines:<br><br>* [DllImport("func.dll")]<br>* public static extern void helloworld();<br><br>And this compiled, but .NET threw an access violation at me when the function ran.  Actually, I fixed some of the gcc flags and got it instead to throw a NullReference exception when the function returned.  Since I was skeptical about gcc, I tried compiling a hand-rolled ansi c file that contained the equivalent helloworld function with basically the same gcc command as above, ran the .NET program and the function ran fine (printed "Hello World" to the console).  It shouldn't be anything with the calling convention or anything either since it looks like the c file produced by scheme declares the helloworld function as __cdecl.  I know that the Gambit-C code includes a bunch of other stuff though (note how I had to link the winsock libraries), so it must be somewhere in there that I'm not compiling it right or something.
<br><br>I found the Visual Studio solution files in the gambit directory and tried compiling gambit to a windows shared lib to see if that would help.  I recompiled the Gambit-C code with visual studio and linked gambit in to a complete dll, ran the .NET app again, and now it's giving me an exception saying it can't find an entry point in the dll for the helloworld function.
<br><br>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)?
<br><br>Thanks,<br>James<br>