Interface to c++ code



I know that perhaps in the future I could use cxx, but for now that doesn’t seem an option because it requires a non-standard build of julia. So I’m playing with ccall interface.

I want to use code that represents multi-dimension c++ arrays using ndarray library
It should be simple to convert Array from julia to c++ nd::array with a c-code wrapper, and conversion could be automatic using cconvert mechanism. I’m thinking I could represent this ndarray type in julia with a type holding a void* pointer.

I don’t know how to go in the other direction: returning a c++ nd::array to julia. Even if I could arrange to convert a raw pointer to the data into a julia array, that doesn’t address the memory management.

Any ideas?


I believe that the cxx package just works on 0.5.


I’m happy to hear that cxx just works with 0.5. Unfortunately, I’m trying
to use fedora packaged julia, which doesn’t include julia source. It looks
like the source is needed.

Without it I get:

INFO: Building Cxx
writing path.jl file
Tuning for julia installation at /usr/bin with sources possibly at
INFO: Building julia binary build
Not building debug library because corresponding julia DEBUG library does
not exist.
Not building release library because corresponding julia RELEASE library
does not exist.
To build, simply run the build again once the library at
To build, simply run the build again once the library at
has been built.
has been built.
 cc -E -P -I/usr/bin/../../src/support -I/usr/bin/../include
-Isrc/clang-3.7.1/lib -Ibuild/clang-3.7.1/include -Isrc/clang-3.7.1/include
-Isrc/llvm-3.7.1/include -Ibuild/llvm-3.7.1/include -DJULIA
../src/cenumvals.jl.h > build/clang_constants.jl
/bin/sh: build/clang_constants.jl: No such file or directory
BuildBootstrap.Makefile:175: recipe for target 'build/clang_constants.jl'
make: *** [build/clang_constants.jl] Error 1
=================================================[ ERROR: Cxx

LoadError: failed process: Process(`make -j4 -f BuildBootstrap.Makefile
BASE_JULIA_BIN=/usr/bin BASE_JULIA_SRC=/usr/bin/../..`, ProcessExited(2))
while loading /home/nbecker/.julia/v0.5/Cxx/deps/build.jl, in expression
starting on line 41

Looking at BuildBootstrap.Makefile, it looks to me that BASE_JULIA_SRC
needs to point to julia sources
Running manually I get:

make -j4 -f BuildBootstrap.Makefile BASE_JULIA_BIN=/usr/bin
BuildBootstrap.Makefile:6: /usr/bin/../../deps/Versions.make: No such file
or directory
BuildBootstrap.Makefile:7: /usr/bin/../../Make.user: No such file or
make: *** No rule to make target '/usr/bin/../../Make.user'.  Stop.


I don’t think the julia developers are involved in maintaining the linux binaries. There are recommended installation instructions for fedora on


I don’t think that will help. The instructions say to use

sudo dnf copr enable nalimilan/julia
sudo yum install julia

It looks like the packages from copr (nalimilan/julia) are exactly the same as the standard julia packages from fedora, which I already have installed - they don’t contain the needed files e.g, deps/Versions.make that the Makefile for Cxx expects.


We’re looking into it.


See this Cxx issue for an analysis of the problem and a temporary hack.