https://github.com/luizirber/sourmash_cpp
https://github.com/luizirber/sourmash_cpp
sourmash
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/luizirber/sourmash_cpp
- Owner: luizirber
- Created: 2019-03-28T23:19:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-28T22:45:52.000Z (over 5 years ago)
- Last Synced: 2025-03-15T14:56:47.486Z (7 months ago)
- Topics: sourmash
- Language: C++
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compiling a C++ Program with a Statically-Linked Rust Library Using CMake
This is based on https://github.com/AndrewGaspar/cmake_including_rust
but using sourmash as an example.
#### Project Set-UpThis is an test case for adding Rust to a C++ project that is currently being
compiled using CMake, through the ExternalProject module. It's desired to have
this library be *statically* linked (using a `*.a` file) vs. dynamically-linked (using a `.so` file).Clone with submodules:
```
$ git clone https://github.com/luizirber/sourmash_cpp
$ cd sourmash_cpp
$ git submodule update --init --remote --recursive
```The project can be built by doing the following:
```
$ mkdir -p _build
$ cd _build
$ cmake ..
$ make
```The set-up is currently the following:
```
.
├── CMakeLists.txt
├── README.md
├── sourmash
│ ├── include
│ │ └── kmer_min_hash.hh
│ ├── Cargo.toml
│ └── src
│ └── ...
└── src
└── main.cpp
```The Rust library is compiled using `cargo build` through the ExternalProject module in CMake.
The `Cargo.toml` file for that project specifies that both a static and dynamic library should be built,
by specifying `crate-type = ["staticlib","cdylib"]` under `[lib]`.### Links from the original repo
Reddit thread about this:
- https://www.reddit.com/r/rust/comments/8vnf2h/statically_linking_a_rust_program_for_c/
- https://github.com/TheYokai/rust-cpp-cmakeRust Embedded's "A little Rust with your C":
- https://rust-embedded.github.io/book/interoperability/rust-with-c.htmlA project using CMake and Rust to run Rust on a BBC micro:bit (search for ExternalProject):
- https://github.com/rossng/microbit-rust-hal