So I built and installed Cxx and then attempted to use it with embedded 
Julia and was successful.  The tricky part is pretty tricky especially for
someone not familiar how the whole thing is laid out,  I've put most of 
what I did in this gist 
<https://gist.github.com/waTeim/ec622a0630f220e6b3c3>

Step 1.  Build and run make install
Step 2.  While still in the top level source directory, install Cxx as per 
the Cxx webpage
Step 3.  Take the installed directory structure and put it in an installed 
location.
Step 4.  There are additional include files that Cxx needs access to after 
it has built whenever c++ source needs to be compiled, they can be found
in the following directories relative to the source tree root.

usr/include/{clang,llvm,llvm-c}

usr/lib/clang/

Cxx attempts to access the files in these directories when it gets imported, 
and although addIncludeDir is supposed to help here, I could not make it work 
like that, so i ended up copying all of this to the installed directory (see 
the gist).

Step 5.  In addition for embedding the relative paths are off, so a couple of 
symbolic links need to be added.

Step 6 access Cxx from embedding framework and I have some show and tell here 
for that

Consider the following file (index.js) this is taken from the Cxx example page, 
I simplified
it to merely good ol' hello world


var julia = require('node-julia');
 
julia.eval('using Cxx');
julia.eval('cxx""" #include<iostream> """');
julia.eval('cxx""" void mycppfunction() { std::cout << "hello world" << 
std::endl; } """');
julia.eval('julia_function() = @cxx mycppfunction()');
 
 
julia.exec('julia_function');


and when run:

bizarro% node index.js 

hello world
So that's JITed-C++ within JITed-Julia within JITed-Javascript, which I 
think is a first.
It's pretty slow because of all of the compiling going on, and there's a 
bunch of eval
where there could be something else, but I think pre-compilation will fix 
that.

Pretty exciting.


Reply via email to