DEV Community

Discussion on: Calling C code from Rust

Collapse
 
kgrech profile image
Konstantin Grechishchev

What is the output of the

rustc -l static=vec -L. src/main.rs
Enter fullscreen mode Exit fullscreen mode

command?

Is it executable or is it an object file? If it is an object file, what is the format of it?

It is possible to compile multiple rs files and link them to executable without using cargo?

Collapse
 
samkevich profile image
Yury Samkevich

This command outputs executable. rustc has an option --emit obj to output an object file. I believe the format of object file depends on platform. On macOS it's Mach-O format.
Compilation unit in rust is crate, not file, so It seems possible to compile multiple crates and link them in executable with standard linker (like ld), but you also need to link rust std somehow (if you use it).