What is the easiest way to call C++ code from Rust

I've been looking around for a crate that allows me to run prediction with a pre-trained TensorFlow (TF) model, but I haven't found any. I'd like to avoid linking to TF as it's quite bulky. In C++ we used to solve that task with frugally-deep library. So now the question is:

  • what is the simplest way to call just (literally) two functions from a C++ header-only library? I can write a middle-layer code, say in C or C++ for that
  • how to organize this in a cargo-managed project?

You might want to check out the cxx crate for this sort of thing.

1 Like