Hi Sean,<br><br>I'm not sure whether this will solve your exact problem, but here's a full example of generating a shared library (.so) where functions are implemented in Scheme and called from C:<br><br><a href="http://toute.ca/tmp/gambit_dynamic_library.tar.gz">
http://toute.ca/tmp/gambit_dynamic_library.tar.gz</a><br><br>Just run "make test" to see it work.<br><br>Hope this helps,<br><br><br>Guillaume<br><br><br><br>On 2/6/07, <b class="gmail_sendername">Sean D'Epagnier
</b> <<a href="mailto:sean@depagnier.com">sean@depagnier.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sorry I forgot to insert my message:<br><br>I have a program written in c that dlopens shared libraries<br>that contain math functions.  I would like to have the option<br>to write these functions in scheme without adding too much
<br>plumbing to the c code.  I would just give it the .so name<br><br>I tried to use the c-define special form as it can wrap regular<br>scheme procedures.  I compiled the output from gsc to a .so<br>file using gcc, and dlopened it with a simple c program, I got
<br>the function pointer, but when I called it I get:<br><br>Program received signal SIGSEGV, Segmentation fault.<br>0x00002aaaab31acf5 in ___garbage_collect () from ./libtest.so<br><br>I saw the server.scm and client.c example in the /tests directory.
<br>Would it make sense to put this setup code in the shared library's<br>init routine?  What if I load multiple libraries this way?<br><br>For a test I put this setup code in the sample c program, but it<br>requires the "#define SCHEME_LIBRARY_LINKER" macro to be set to a name,
<br>this is a bit of a problem since I don't know the name and I want<br>to load an arbitrary number of libraries.<br><br>I did for a test put in the name of the sample library, and it did<br>work when I called the function pointer I got from dlsym.
<br><br>Any hints on how to get around the SCHEME_LIBRARY_LINKER restriction?<br><br>Thanks<br>Sean<br>_______________________________________________<br>Gambit-list mailing list<br><a href="mailto:Gambit-list@iro.umontreal.ca">
Gambit-list@iro.umontreal.ca</a><br><a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br></blockquote></div><br>