Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

From Nothing To Hello World

This page explain the quickest way to test a program on Redox. This tutorial doesn't build Redox from source.

In this example we will use a "Hello World" program written in Rust.

  1. Create the tryredox folder.

    mkdir -p ~/tryredox
    
  2. Navigate to the tryredox folder.

    cd ~/tryredox
    
  3. Download the script to configure Podman and download the Redox build system.

    curl -sf https://gitlab.redox-os.org/redox-os/redox/raw/master/podman_bootstrap.sh -o podman_bootstrap.sh
    
  4. Execute the downloaded script.

    time bash -e podman_bootstrap.sh
    
  5. Enable the Rust toolchain in the current shell.

    source ~/.cargo/env
    
  6. Navigate to the Redox build system directory.

    cd ~/tryredox/redox
    
  7. Create the .config file and add the REPO_BINARY environment variable to download the pre-compiled packages.

    echo "REPO_BINARY?=1 \n CONFIG_NAME?=my-config" >> .config
    
  8. Create the hello-world recipe folder.

    mkdir recipes/other/hello-world
    
  9. Create the source folder for the recipe.

    mkdir recipes/other/hello-world/source
    
  10. Navigate to the recipe's source folder.

    cd recipes/other/hello-world/source
    
  11. Initialize a Cargo project with the "Hello World" string.

    cargo init --name="hello-world"
    
  12. Create the hello-world recipe configuration.

    cd ~/tryredox/redox
    
    nano recipes/other/hello-world/recipe.toml
    
  13. Add the following to the recipe configuration:

    [build]
    template = "cargo"
    
  14. Create the my-config filesystem configuration.

    cp config/x86_64/desktop.toml config/x86_64/my-config.toml
    
  15. Open the my-config filesystem configuration file (i.e., config/x86_64/my-config.toml) and add the hello-world package to it.

    [packages]
    # Add the item below
    hello-world = "source"
    
  16. Build the Hello World program and updae the Redox image.

    time make prefix rp.hello-world
    
  17. Start the Redox virtual machine without a GUI.

    make qemu gpu=no
    
  18. At the Redox login screen, write "user" for the user name and press Enter.

  19. Run the "Hello World" program.

    helloworld
    
  20. Shut down the Redox virtual machine.

    sudo shutdown