On Aug 11, 4:26 pm, Chouser <chou...@gmail.com> wrote:
> On Wed, Aug 11, 2010 at 5:18 AM, mac <markus.gustavs...@gmail.com> wrote:
>
> > It is certainly theoretically possible to call C++ from Clojure/Java
> > but it requires deep knowledge and lots of code for each C++ compiler
> > one would like to support.
>
> I've done a fair amount of work getting specific C++ libraries to
> work with Clojure.  I recommend swig, but even with that it's
> a messy and error-prone process, requires integration with your
> AOT build process, etc.

Yes, something like swig is probably the best option, but that falls
under the wrap in C category in my mind. I didn't mean to sound like
you have to do it manually, a tool is of course nicer if it's
possible.

What I meant by "theoretically possible to call" was calling without
wrappers, using the same technique as JNA. But that's a real mess
because at the very least it requires a library like clj-native (or
rather JNA in this case) to handle C++ name mangling. And to be
complete you would also need to handle virtual function dispatch and
exceptions. And that's no small task thanks to the compilers being so
different.

/Markus

On Aug 11, 4:26 pm, Chouser <chou...@gmail.com> wrote:
> On Wed, Aug 11, 2010 at 5:18 AM, mac <markus.gustavs...@gmail.com> wrote:
>
> > It is certainly theoretically possible to call C++ from Clojure/Java
> > but it requires deep knowledge and lots of code for each C++ compiler
> > one would like to support.
>
> I've done a fair amount of work getting specific C++ libraries to
> work with Clojure.  I recommend swig, but even with that it's
> a messy and error-prone process, requires integration with your
> AOT build process, etc.
>
> Once that's all set up for each individual C++ lib, the Clojure
> code you write to use it can look as good and work as well as any
> Java interop code, so quite well and naturally.
>
> --Chouserhttp://joyofclojure.com/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to