'How do I compile Rust code without linking, i.e. produce object files?

Due to how the LGPL works, compiling Rust code to an object file without linking would be useful to be able to do. However, I cannot find any documentation on how to do this. I checked rustc's help section and searched, but couldn't find anything, which brings me to my question: How do I tell rustc to not link and produce object files that later can be linked?



Solution 1:[1]

Use the compiler flag --emit=obj.

cargo rustc -- --emit=obj

The compiled object files will be sitting in target/debug/deps.

See also:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 E_net4 - Krabbe mit Hüten