Rust and C++ #1847
Replies: 7 comments 5 replies
-
Thanks for the writeup! Did not know about compiling Rust from the C++ side, will need to try that in some of my projects. |
Beta Was this translation helpful? Give feedback.
-
thanks for sharing @hunger |
Beta Was this translation helpful? Give feedback.
-
To the best of your knowledge, is there a way to compile the rust codebase and provide a static lib to c++ developers who use the bindings?
I believe that a c++ dev who just wants to call c++ functions, that in turn call a rust backend, would not want to deal with compiling rust over and over (not to mention the difficulty to distribute code in many scenarios)
What do you suggest in that case?
…On Tue, Nov 15, 2022, at 8:09 PM, Tobias Hunger wrote:
Yes, your rust code is what those bindings call into, so they need to be available when building the C++ project.
—
Reply to this email directly, view it on GitHub <#1847 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACYTR32HEKWCPGI44B3OGELWIPNXLANCNFSM6AAAAAAR5YGWKU>.
You are receiving this because you commented.Message ID: ***@***.***>
--
*Francesco Gadaleta, PhD*
Founder - Amethix Technologies
W: https://amethix.com
T: +32 478 99 89 36
Schedule a call <https://harmonizely.amethix.com/francesco>
|
Beta Was this translation helpful? Give feedback.
-
Interesting article, although it can be incremented under new existing alternatives available.
Note: Among all the alternatives presented, diplomat best suits the purpose of the slint. |
Beta Was this translation helpful? Give feedback.
-
Interesting indeed. Added all of them to my list.
In my case, I have a Rust codebase that has it's own entry point (main.rs) and serves requests and does other things.
What i need however is that a c++ dev can write her own c++ program and call some Rust functions from the codebase (and continue interacting with her c++ app).
So imagine a server that processes requests (Rust) and a client (c++) that builds messages (using Rust bindings) and makes requests.
As a C++ dev, I would like to ignore the Rust service completely, except when I just make the request and/or build my message. By ignore I mean that I might not be able to compile the Rust part.
…On Tue, Nov 15, 2022, at 9:14 PM, Matheus C. França wrote:
Interesting article, although it can be incremented under new existing alternatives available.
* `safer_ffi` <https://github.com/getditto/safer_ffi> is a framework that helps you write foreign function interfaces (FFI) without polluting your Rust code with unsafe { ... } code blocks while making functions far easier to read and maintain.
* `UniFFI` <https://github.com/mozilla/uniffi-rs/> is a tool that automatically generates foreign-language bindings targeting Rust libraries.
* `diplomat` <https://github.com/rust-diplomat/diplomat> is a experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code.
—
Reply to this email directly, view it on GitHub <#1847 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACYTR35AFN3LDR3UIFZNCQLWIPVLLANCNFSM6AAAAAAR5YGWKU>.
You are receiving this because you commented.Message ID: ***@***.***>
--
*Francesco Gadaleta, PhD*
Founder - Amethix Technologies
W: https://amethix.com
T: +32 478 99 89 36
Schedule a call <https://harmonizely.amethix.com/francesco>
|
Beta Was this translation helpful? Give feedback.
-
Amazing!
Does this apply to a cxx bridge too?
…On Wed, Nov 16, 2022, at 9:22 AM, Olivier Goffart wrote:
To create a static lib, you can use the `crate-type = ["staticlib"]` field in the Cargo.toml <https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-crate-type-field>
In Slint, our runtime is implemented in Rust but we provide a C++ API. We want our C++ user to not bother with rust, so we provide both binary package, or just a way to compile, with corrosion.
That way the C++ user only need to have the rust compiler instead to compile from source, and it is only once. They don't even need rust when using binary package.
Thanks to the corrosion project
Here is our C++ documentation for how to install and build https://slint-ui.com/releases/0.3.1/docs/cpp/cmake.html as you see, there is little mention of rust.
You can see how this is implemented with corrosion in https://github.com/slint-ui/slint/blob/master/api/cpp/CMakeLists.txt
—
Reply to this email directly, view it on GitHub <#1847 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACYTR3YUMUVQV45WWOMBKXDWISKUJANCNFSM6AAAAAAR5YGWKU>.
You are receiving this because you commented.Message ID: ***@***.***>
--
*Francesco Gadaleta, PhD*
Founder - Amethix Technologies
W: https://amethix.com
T: +32 478 99 89 36
Schedule a call <https://harmonizely.amethix.com/francesco>
|
Beta Was this translation helpful? Give feedback.
-
in my particular case i have control over the rust and the c++ side.
i guess cxx makes more sense there.
maybe cxx + staticlib compilation to allow a c++ dev to recompile her code just linking to the pre-compiled bridge
…On Wed, Nov 16, 2022, at 4:22 PM, Matheus C. França wrote:
However, the `diplomat` continues to refer to the `cxx` based on the ffi investigation - ICU4X's <https://docs.google.com/document/d/1Y1mNFAGbGNvK_I64dd0fRWOxx9xqi12dXeLivnxRWvA/mobilebasic?resourcekey=0-l9QvvqXW7cC-TrfLWt7nZw#heading=h.mwn95cq0jjht>.
https://github.com/rust-diplomat/diplomat/blob/main/docs/design_doc.md
—
Reply to this email directly, view it on GitHub <#1847 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACYTR37N46DWV4RLJDEJWC3WIT3ZTANCNFSM6AAAAAAR5YGWKU>.
You are receiving this because you commented.Message ID: ***@***.***>
--
*Francesco Gadaleta, PhD*
Founder - Amethix Technologies
W: https://amethix.com
T: +32 478 99 89 36
Schedule a call <https://harmonizely.amethix.com/francesco>
|
Beta Was this translation helpful? Give feedback.
-
Discussion thread for the blog post "Rust and C++"
Beta Was this translation helpful? Give feedback.
All reactions