last update: 2017 08 17
index
contact
  1. Operating system

    I use Arch Linux (antergos) as operating system.
  2. How to install Rust

    By using rustup.

    Execute in the terminal:
    curl https://sh.rustup.rs -sSf | sh
    This downloads, installs and executes rustup that can:
    • install and update Rust and cargo.
    • adapt the PATH variable for the current user.

You can update the installation by this command:
rustup update
  • How to create a project

    I advise to use cargo to create and build (compile) a Rust project.

    Execute in the terminal for a program project (with an executable program):
    cargo new project_name --bin

    Execute in the terminal for a library project (with an executable test program):
    cargo new project_name

    Execute in the terminal and in the project folder to build (compile) the project:
    cargo build
  • How to install the tools

    I advise the use of Visual Studio Code with: The .tar.gz version of Visual Studio Code works fine on my Arch linux installation; just decompress and launch the /bin/code executable.
  • How to install Rust (rls)

    Install the "Rust (rls)" extension from rust-lang in VS Code.
    Accept to install whatever the extension requests.
    AFAIK the local rustup installation is used.
  • How to install LLDB Debugger

    Install the "LLDB Debugger" plugin in VS Code.
    Then install the other tools as described in the following lines or here.
    The LLDB Debugger requires LLDB.
    With Arch Linux I can install it by using pacman.

    In the OS terminal execute as root user:
    pacman -S lldb

    You can obtain root rights by typing in the terminal:
    su
    The command means "switch user" and switches to the root user if not given a user name as argument.
  • How to use LLDB Debugger

    Build the project with cargo (cargo build).
    Start VS Code.
    Open the project folder created with cargo.
    The LLDB Debugger added the menu bar entry "Debug" from where the debugger can be started.
    After the start of the LLDB Debugger, VS Code will create the launch.json file in the .vscode directory for the configuration of the VS Code tools and plugins for the VS Code project.
    The LLDB Debugger requires a configuration entry in the launch.json as described in the following lines or here.
    In my case the slightly inadequate entry is created by default:
    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "lldb",
                "request": "launch",
                "name": "Debug",
                "program": "${workspaceRoot}/<your program>",
                "args": [],
                "cwd": "${workspaceRoot}"
            }
        ]
    }

    The line with the executable program path must be adapted by replacing <your program> by /target/debug/xxx like so:
    "program": "${workspaceRoot}/target/debug/xxx",
    where xxx is the name of the executable in the ${workspaceRoot}/target/debug/ directory.
    If the project was created as program project then the name of the executable is the name of the project e.g. "hello_world".
    If the project was created as library project then the name of the executable is the name of the project followed by some id code. The executable executes the test procedures in the "tests" module in the lib.rs file.

    Now you can set breakpoints and start the debugger again and it should work.