File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -28,3 +28,18 @@ When using QML with CXX-Qt [QML modules](https://doc.qt.io/qt-6/qtqml-writing-a-
28
28
This allows for attributes such as ` #[qml_element] ` to register the QObject with the QML type system without any C++ code.
29
29
30
30
See [ ` QmlModule ` documentation] ( https://docs.rs/cxx-qt-build/latest/cxx_qt_build/struct.QmlModule.html ) for more details.
31
+
32
+ ## Splitting a project into multiple crates
33
+
34
+ As your project grows, it can be helpful to organize your code into multiple Rust crates. If your ` main ` function is
35
+ in Rust ([ Cargo is your only build system] ( ../getting-started/4-cargo-executable.md ) ), simply add the crates as
36
+ dependencies of the top level binary crate in its Cargo.toml file.
37
+
38
+ If your ` main ` function is in C++, you can only link one staticlib Rust crate into C++, otherwise linking
39
+ would fail with duplicate symbol errors from multiple Rust runtimes. So, create one top level staticlib crate to link
40
+ into the C++ application. Specify your other crates as normal Rust library (rlib) dependencies
41
+ in the staticlib crate's Cargo.toml. You must reference the symbols of the Rust dependencies within the staticlib crate;
42
+ if you don't need those symbols in Rust code, you can add ` extern crate crate_name; ` statements in the staticlib's lib.rs file.
43
+ Refer to the [ meta_project example] ( https://github.com/KDAB/cxx-qt/blob/main/examples/meta_project ) for how to set this up.
44
+ Note that this requires Rust compiler features that were [ stabilized] ( https://github.com/rust-lang/rust/pull/113301 )
45
+ in Rust 1.74.
You can’t perform that action at this time.
0 commit comments