windows10 のwsl(ubuntu)にrustをインストールする
-
下記のコマンドでターミナルに実行する
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
インストール後
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: linker ``cc`` not found
は発生すると、gccをインストール必要です。
sudo apt install build-essential
でインストールする
sudo apt-get update --fix-missing
一部取得できないpackageがあれば、このコマンドを実行する -
wsl(ubuntu)にもLLDBをインストールする
sudo apt install lldb
でインストールする。lldb --version
でインストール結果を確認する -
launch.jsonファイル作成
"program": "${workspaceFolder}/hello_cargo/target/debug/hello_cargo",
のようにcargo buildで作ったバイナリobjのパスを指定するとデバッグ可能になる