Compile and link examples wanted

i can find things where cargo builds and compiles and links the app.
i need the other way:

a) rustc is invoked by a makefile/shell script not cargo

b) i link a rust object (from the above) to my larger c application.

c) rustc/cargo creates a static library that my c code can call/use

i have seen a build.rs example that attempts to compile a single c source file for me -

that is not desired - i do not want to rebuild/rewrite a HUGE gnu-automake project in build.rs i need it another way…

I don't know if it solves your specific problem, because I have not looked at it myself, but I'll mention it just in case it scratches your itch: I've read that there are other build systems that can build Rust projects without invoking cargo internally, apparently in order to be able to be more flexible about linking with "foreign" object files.

I saw someone tweet about it just a few days ago, but unfortunately I don't remember which build system was used. bazel or buck2, perhaps?

if you want to skip cargo completely and manually invoke rustc, here's an example Makefile by tsoding:

note, this project is in non-idomatic rust on purpose, for entertainment and education, keep that in mind.

the biggest challenge is dependency management without cargo. see also this article:

1 Like

I don't know about buck2, but I think both bazel and meson support building of rust project, but I don't know how well they can manage dependency crates.

here's an earlier thread on this topic:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.