When coding in C++, I have the habit to create static libs to speed up a bit my compilation times and separate concerns better. Coupled with a fast linker, the overall experience is better (speed and efficiency).
Note: I only plan to develop on linux for linux. No other OS is involved in my work. I manage the compiler version.
Now, my next project involves Rust. I would like to be able to create a crate and precompile it.
I would like to avoid having to recompile all the libs, all the time.
Linkage page talks about
#![crate_type = "staticlib"].
Is it what I should use ? Is there a current/incoming way to achieve what I want?
Please note that I only ever wrote 10 lines of Rust up to that day, so I am a real beginner in the Rust ecosystem (but now, it is time to change that).
I suggest you write some code following tutorials and when you start adding crates you will visually see what happens.
A reply about static libraries is an XY problem. The linkage page is advanced reference documentation detail and not helpful when just starting out.
Cargo doesn't recompile crates in a project unless they or their dependencies change.
I may be a beginner in Rust but not in C++ or even C. I definitely will hang with the details
Ah that is what I wanted to make sure of.
By the way, there are ways to make Cargo's cache ineffective so that you end up with a lot of redundant rebuilding; most often it is due to alternating between two different sets of compiler flags specified by environment variable (e.g. in an IDE and in a separate terminal).
If you find yourself in this situation, make sure all builds have the same flags, or ask us for help — nobody should have to live with full rebuilds in their workflow.
Thanks a lot,
I will definitely come back, I -really- like what the language enables me to do,and the way it does.
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.