- サンプルコードを実行しながら理解できるように、C++の開発環境を構築する。
エディション Windows 10 Home
バージョン 22H2
インストール日 2023/02/27
OS ビルド 19045.2673
エクスペリエンス Windows Feature Experience Pack 120.2212.4190.0
- WSLが利用可能かを確認する。
- コマンドプロンプトを起動(一般ユーザ権限でOK)して、wslと入力して、wslの利用方法が表示されたということは、WSLはまだインストールされていないということ。
>wsl
Copyright (c) Microsoft Corporation. All rights reserved.
使用方法: wsl.exe [Argument]
引数:
--install
・・・
- CPUの仮想化機能の確認
- WSL2を利用するには、CPUの仮想化機能を有効にする必要がある。
- CPUの仮想化機能が有効かを確認する。
- タスクマネージャ(Control-Alt-Delete)→ 詳細 → 「パフォーマンス」タブ → 仮想化:有効 !になっているのでOK。「無効」ならBIOSの設定が必要となる。
>wsl --install
要求された操作には管理者特権が必要です。
インストール中: 仮想マシン プラットフォーム
仮想マシン プラットフォーム はインストールされました。
インストール中: Linux 用 Windows サブシステム
Linux 用 Windows サブシステム はインストールされました。
インストール中: Linux 用 Windows サブシステム
Linux 用 Windows サブシステム はインストールされました。
インストール中: Ubuntu
Ubuntu はインストールされました。
要求された操作は正常に終了しました。変更を有効にするには、システムを再起動する必要があります。
Ubuntu は既にインストールされています。
Ubuntu を開始しています...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: whoami
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This message is shown once a day. To disable it please create the
/home/whoami/.hushlogin file.
whoami@PC-NAME:~$
Microsoft Windows [Version 10.0.19045.2673]
(c) Microsoft Corporation. All rights reserved.
C:\Users\whoami>wsl
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
whoami@PC-NAME:/mnt/c/Users/whoami$
$ sudo apt update
$ sudo apt upgrade -y
- C++開発環境のインストール
- GCC版のg++をインストールする(g++だけではないけれど)。
- g++のバージョンは、11.3.0
$ sudo apt install build-essential
$ g++ --version
g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0