Page 1 of 1

How to embed SBCL in a C++ app?

Posted: Tue Aug 05, 2008 9:10 am
by pTymN
Has anyone had experience embedding SBCL in a C++ app? The C++ app has the main(), and I would like to be able to start up or embed SBCL in the C++ app without the use of pipes or other funky cross process mechanisms. I'm looking for a static or DLL link of SBCL into my game. For reference, here's how I am currently using Corman CL:

1) C++ .exe starts up
2) App calls LoadModule("lisp-file-compiled-into-dll.dll")
3) That dll implicitly loads CormanLispServer.dll (The corman runtime engine)
4) There is also a .img file that contains all the startup heap stuff, and I think that it also is implicitly loaded in step #3.

I am having trouble locating a tutorial on how to embed sbcl in another app directly. Your helpful suggestions are much appreciated!

Re: How to embed SBCL in a C++ app?

Posted: Tue Aug 05, 2008 9:48 am
by ramarren
As far as I am aware, this is outright impossible, because SBCL memory model has to many assumptions about owning the process or somesuch... But I never looked into SBCL internals. Still, I have never seen any mention of that, and usually for embedding an open-source Lisp ECL is recommended.

Re: How to embed SBCL in a C++ app?

Posted: Tue Aug 05, 2008 10:39 am
by pTymN
The C++ to lisp calls are only for events in an event driven paradigm. So the alternative would be for the C++ to queue up events and the Lisp to poll the events instead of the C++ calling lisp directly when events are generated.

Re: How to embed SBCL in a C++ app?

Posted: Tue Aug 05, 2008 11:18 am
by pTymN
If anyone has a guide for how to do this, I'd still appreciate it. The C++ app uses a sample framework that comes with the 3d graphics engine, and I really don't feel like opening that can of worms. It seems like it should be easier to compile sbcl as a dll than to manually dig around for everything that the sample framework is doing.

Re: How to embed SBCL in a C++ app?

Posted: Tue Aug 05, 2008 5:37 pm
by Paul Donnelly
I'm pretty sure this is impossible without major changes to sbcl. The other way around might even be easier. Why not use a Lisp that's meant to be embedded?

Re: How to embed SBCL in a C++ app?

Posted: Wed Aug 06, 2008 12:59 am
by vityok
Especially that the ECL had a new release recently.