build.rs, link, and pkg-config
In FFI, declaring the C function is only the first step:
unsafe extern "C" {
fn sensor_read(out: *mut u8, len: usize) -> i32;
}
This only tells Rust that a C ABI function named sensor_read exists.
The linker still needs to know:
which library contains this function?
where is the library file?
what other dependent libraries are needed?
during cross compilation, are these target libraries or host libraries?
C projects usually handle this with Makefiles, CMake, pkg-config, sysroots, and cross toolchains. Rust projects use #[link], build.rs, and build dependencies for the same job.