• Home
  • Raw
  • Download

Lines Matching +full:rust +full:- +full:src

1 {{#title Other build systems — Rust ♡ C++}}
6 - Produce the CXX-generated C++ bindings code.
7 - Compile the generated C++ code.
8 - Link the resulting objects together with your other C++ and Rust objects.
12 CXX's Rust code generation automatically happens when the `#[cxx::bridge]`
13 procedural macro is expanded during the normal Rust compilation process, so no
18 - Use the `cxxbridge` command, which is a standalone command line interface to
23 $ cxxbridge src/bridge.rs --header > path/to/bridge.rs.h
24 $ cxxbridge src/bridge.rs > path/to/bridge.rs.cc
27 It's packaged as the `cxxbridge-cmd` crate on crates.io or can be built from
30 - Or, build your own code generator frontend on top of the [cxx-gen] crate. This
33 [cxx-gen]: https://docs.rs/cxx-gen
39 ### Linking the C++ and Rust together
41 When linking a binary which contains mixed Rust and C++ code, you will have to
42 choose between using the Rust toolchain (`rustc`) or the C++ toolchain which you
45 Rust does not generate simple standalone `.o` files, so you can't just throw the
46 Rust-generated code into your existing C++ toolchain linker. Instead you need to
49 * Use `rustc` as the final linker. Pass any non-Rust libraries using `-L
50 <directory>` and `-l<library>` rustc arguments, and/or `#[link]` directives in
51 your Rust code. If you need to link against C/C++ `.o` files you can use
52 `-Clink-arg=file.o`.
55 `cargo` to generate a _single_ Rust `staticlib` target and pass that into your
58 * If you need to link multiple Rust subsystems, you will need to generate a
60 include multiple Rust `rlib`s. Multiple Rust `staticlib` files are likely
63 Passing Rust `rlib`s directly into your non-Rust linker is not supported (but
66 See the [Rust reference's *Linkage*][linkage] page for some general information
69 [linkage]: https://doc.rust-lang.org/reference/linkage.html
71 The following open rust-lang issues might hold more recent guidance or
72 inspiration: [rust-lang/rust#73632], [rust-lang/rust#73295].
74 [rust-lang/rust#73632]: https://github.com/rust-lang/rust/issues/73632
75 [rust-lang/rust#73295]: https://github.com/rust-lang/rust/issues/73295