Creating a new Rust project with Cargo
First, we'll demonstrate creating a new "Hello, world!" project with kos-cargo
. This will follow the cargo-hello
example included in the Rust-for-Dreamcast repo.
In a directory of your choosing, let's invoke kos-cargo
to create a new project and then enter the directory:
kos-cargo new hello
cd hello
Let's add our kos-rs crate to gain access to current KallistiOS bindings. Open Cargo.toml
in your text editor and add:
[dependencies]
kos = { package = "kos-rs", git = "https://github.com/dreamcast-rs/kos-rs" }
Now we can open up src/main.rs
and write our "Hello, world!" example code:
fn main() { println!("Hello, world from Rust!"); }
Now we can use kos-cargo build
to build our project. If all goes well, there will be a target/sh-elf/debug/hello.elf
file that can be sent to the Dreamcast with dc-tool
.
If you have KOS_LOADER
set in the environ.sh
file, you can invoke it directly with kos-cargo run
.