-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 6-Feb-07, at 11:46 PM, Sean D'Epagnier wrote:
Sorry I forgot to insert my message:
I have a program written in c that dlopens shared libraries that contain math functions. I would like to have the option to write these functions in scheme without adding too much plumbing to the c code. I would just give it the .so name
I tried to use the c-define special form as it can wrap regular scheme procedures. I compiled the output from gsc to a .so file using gcc, and dlopened it with a simple c program, I got the function pointer, but when I called it I get:
Program received signal SIGSEGV, Segmentation fault. 0x00002aaaab31acf5 in ___garbage_collect () from ./libtest.so
I saw the server.scm and client.c example in the /tests directory. Would it make sense to put this setup code in the shared library's init routine? What if I load multiple libraries this way?
For a test I put this setup code in the sample c program, but it requires the "#define SCHEME_LIBRARY_LINKER" macro to be set to a name, this is a bit of a problem since I don't know the name and I want to load an arbitrary number of libraries.
I did for a test put in the name of the sample library, and it did work when I called the function pointer I got from dlsym.
Any hints on how to get around the SCHEME_LIBRARY_LINKER restriction?
My suggestion is this: create a shared library that contains the Gambit runtime library and link each of your math function shared libraries with the Gambit runtime library. So when you load any of the math function libraries, the Gambit runtime library will automatically be loaded (and initialized).
If this is too abstract, let me know and I'll see if I can write some real code for this. What operating system are you using? How do you do your dlopen calls in C?
Marc