4 ms·
Does Cargo support building C or C++ dependencies? I see a lot of projects with a mix of Rust and C/C++ and I’d assumed that just meant I’d have to deal with 2
by schemescape 4y ago
Does Cargo support building C or C++ dependencies? I see a lot of projects with a mix of Rust and C/C++ and I’d assumed that just meant I’d have to deal with 2 build systems.
I looked at Nix to help with multi-language builds (and cross compiling), but only had limited success.
- shakow 4y agoIt could technically do it with a build.rs script, but it typically expects to find the .so/.a on your system.
- jeroenhd 4y agoIt does support calling into other compilers and toolchains through build scripts and such. Take cc-rs[0] for example: this allows building C and C++ files natively without even calling an executable yourself. In practice, I'd expect libraries to just call make/cmake/ninja for you, or (like openssl-sys) ask you to install the necessary libraries using your favourite package manager. [0]: https://github.com/rust-lang/cc-rs https://github.com/rust-lang/cc-rs
- schemescape 4y agoThat’s pretty much what I was looking for, thanks!
- shaunsingh0207 4y agoYes, through a `build.rs` file and crates such as `pkg-config`. Quite a few projects depends on c/c++ source and are merely rust bindings. However, the majority of crates don't require external dependencies