How to embed SBCL in a C++ app?

Discussion of Common Lisp

How to embed SBCL in a C++ app?

Postby pTymN » Tue Aug 05, 2008 9:10 am

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!
pTymN
 
Posts: 20
Joined: Sat Jun 28, 2008 7:15 am
Location: Columbia, SC

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

Postby Ramarren » Tue Aug 05, 2008 9:48 am

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.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

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

Postby pTymN » Tue Aug 05, 2008 10:39 am

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.
pTymN
 
Posts: 20
Joined: Sat Jun 28, 2008 7:15 am
Location: Columbia, SC

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

Postby pTymN » Tue Aug 05, 2008 11:18 am

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.
pTymN
 
Posts: 20
Joined: Sat Jun 28, 2008 7:15 am
Location: Columbia, SC

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

Postby Paul Donnelly » Tue Aug 05, 2008 5:37 pm

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?
Paul Donnelly
 
Posts: 148
Joined: Wed Jul 30, 2008 11:26 pm

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

Postby vityok » Wed Aug 06, 2008 12:59 am

Especially that the ECL had a new release recently.
vityok
 
Posts: 20
Joined: Fri Jul 11, 2008 6:20 am
Location: Kyiv, Ukraine


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 3 guests