For complicated projects, cmake crate should be useful, but for small projects, just use Rust's build.rs.
In the build.rs
, do
fn main() {
cc::Build::new()
.cpp(true)
.file("src/my_lib.cpp")
.compile("lib_my_lib.a");
}
which should be placed in the root of the project. Then simply run cargo build
. For C
files, take off the .cpp(true)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…