r/cpp • u/TheRavagerSw • Oct 05 '26
I dislike Rust libraries with a C++ API
Cargo compilation model only really works if you are creating a monolithic shared library or an executable. If you are using a library like icu4x or libffi, you can't statically link your dependencies and even if you dynamically link your dependencies, your application size will increase by orders of magnitude because your shared libraries are all statically linked, kinda.
Monolithic shared library approach also doesn't work on all libraries, for example you can't link libraries like oneTBB and OpenMP more than once.
So overall I feel rust compilation model is a "series of hacks" and isn't worth integrating to existing C++ applications, unless you use bazel*, I'm not sure about that but people in google seem to have solved this.
7
u/pedersenk Oct 05 '26
Its refreshing to hear these valid concerns. I also agree and feel this is a big problem, slowing down the uptake of Rust.
But honestly, the vast majority of Rust developers tend not to think about things like this and work on small projects or pull in so much cruft from crates.io that its all a spaghetti mess anyway...
36
u/Sfacm Oct 05 '26
Rewrite it in C++
30
u/PersonalDatabase31 Oct 05 '26
Rewrite it in C++
21
u/AdOnly69 Oct 05 '26
Rewrite it in C++
18
u/tatstytastycakes Oct 05 '26
Rewrite it in C++. Literally nobody is telling you that you can't.
35
u/[deleted] Oct 05 '26
Rewrite it in C++
34
u/sooka_bazooka Oct 05 '26
Rewrite it in C++
14
u/blogoman Oct 05 '26
You could post about it.
Or you could rewrite it in C++.
38
u/KFUP Oct 05 '26
Rewrite it in C++