[rust-dev] How to build multiple .rs source files?

Tim Chevalier catamorphism at gmail.com
Mon Apr 9 14:35:26 PDT 2012

On Mon, Apr 9, 2012 at 2:26 PM, Amitava Shee <amitava.shee at gmail.com> wrote:
> Is there a starter project or a Makefile?
> When I try to compile a source file without linking, I get the following
> error
> amitava:learn amitava$ rustc -g -c shape.rs
> shape.rs:1:0: 1:0 error: main function not found
> shape.rs:1 class shape {
>            ^
> error: aborting due to previous errors
> How do I compile several source files to obj files and then link them
> together into an executable?

Hi, Amitava --

A single source file has to contain a function named "main" in order
to be compiled to an executable, much as in C/C++.

Rust's way of organizing multiple source files is called a "crate".
The tutorial explains how they work:


Feel free to ask either here or on the Rust IRC channel (see
https://github.com/mozilla/rust/wiki/Note-development-policy for
details) if you have more questions.


Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt
"Debate is useless when one participant denies the full dignity of the
other." -- Eric Berndt

More information about the Rust-dev mailing list