LoginSignup
3

More than 3 years have passed since last update.

WSL(ubuntu)にrustをインストールする(デバッグまで)

Last updated at Posted at 2020-05-17

windows10 のwsl(ubuntu)にrustをインストールする

  • 下記のコマンドでターミナルに実行する

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

  • >1でデフォルトにインストールする
    rust_install.png

  • インストール後source $HOME/.cargo/envで環境変数の変更を反映する

  • cargo --versionで反映結果を確認する
    cargo 1.43.0 (2cbe9048e 2020-05-03)が出れば問題ないです。

  • サンプルソース作成
    mkdir $HOME/projectsでソースファイルを作成する
    cargo new hello_cargoで「hello_cargo」というプロジェクトを作成する
    cargo runでコンパイルして実行する
    error: linkerccnot foundは発生すると、gccをインストール必要です。
    sudo apt install build-essentialでインストールする
    sudo apt-get update --fix-missing一部取得できないpackageがあれば、このコマンドを実行する

  • debugするため、vscodeに「Rust」と「CodeLLDB」をインストールする
    vscode_install.png

  • wsl(ubuntu)にもLLDBをインストールする
    sudo apt install lldbでインストールする。lldb --versionでインストール結果を確認する

  • launch.jsonファイル作成
    launch01.png
    lldb_select.png
    launch02.png
    "program": "${workspaceFolder}/hello_cargo/target/debug/hello_cargo",のようにcargo buildで作ったバイナリobjのパスを指定するとデバッグ可能になる
    linux_debug.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3