How to configure Clion for rust and c/c++


#1

How can i use clion to call c/c++ code from rust. i want to build a project in which i have to call some c/c++ functions from rust. i have configured rust in clion.


#2

You need two things:

  1. Call c/c++ build system from cargo and link resulted file to rust code
  2. Describe c/c++ functions and types on Rust to call them as ordinary rust functions

To do 1 you can use cc or cmake crates, cmake crate usage you can see for example
here: https://github.com/servo/skia

To do 2 you can use bindgen crate.