The Gambit docs shows examples of building dynamically-loadable libraries to be loaded by Gambit code, and also how to compile shared libraries.
Does anyone have a handy example of compiling a dynamically-loadable library for loading by non-Gambit code, including how to initialize the gambit runtime when the library is loaded? I'd like to compile some of my Gambit code to a library that can be dynamically loaded by a Lispworks app, but frobbing around with compiler flags has yielded no joy so far.
I don't think I need to see an example of doing it from Lispworks; if anyone has, say, a C program that can dynamically load a Gambit library and initialize it properly, that's probably all I need.
Thanks in advance to anyone who can help.
--me
Afficher les réponses par date
Have you looked at the files client.c, server.h and server.scm in the tests directory?
You can embed Gambit in this way and then from C do:
eval_string("(load "lib.o1")");
Marc
On Mar 3, 2019, at 10:06 AM, mikel evins mevins@me.com wrote:
The Gambit docs shows examples of building dynamically-loadable libraries to be loaded by Gambit code, and also how to compile shared libraries.
Does anyone have a handy example of compiling a dynamically-loadable library for loading by non-Gambit code, including how to initialize the gambit runtime when the library is loaded? I'd like to compile some of my Gambit code to a library that can be dynamically loaded by a Lispworks app, but frobbing around with compiler flags has yielded no joy so far.
I don't think I need to see an example of doing it from Lispworks; if anyone has, say, a C program that can dynamically load a Gambit library and initialize it properly, that's probably all I need.
Thanks in advance to anyone who can help.
--me
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list
On Mar 6, 2019, at 7:40 AM, Marc Feeley feeley@iro.umontreal.ca wrote:
Have you looked at the files client.c, server.h and server.scm in the tests directory?
You can embed Gambit in this way and then from C do:
eval_string("(load "lib.o1")");
I haven't; thank you. I'll take a look.
In case it doesn't work out conveniently, or in case anyone else asks for another approach, I did find another way to accomplish the same purpose: I used Xcode to build a dynamic library that linked against a static library that I built with Gambit. In the dylib project I added a C source file that exposed an init function that performs the Gambit startup.
I then loaded it at runtime in a Lispworks image, executed the init, and then tested a few of the simpler library functions; they returned the expected values.
I haven't dealt with unloading the library (in part because I don't expect ever to do that), so my tests didn't execute Gambit's cleanup. Are there bad consequences I should be aware of from being sloppy like that?
Thanks for your kind attention.