2
0

More than 3 years have passed since last update.

Window10にWSL2+Ubuntuを導入し、GDC、DMD、LDCを使ってみた

Last updated at Posted at 2020-10-10

はじめに

遅ればせながら、Window10WSL2Ubuntuを導入しました。
その際に、D言語コンパイル環境を構築したときのメモになります。

Windows 10 環境

2つの環境に導入しました。

  • その1

    • Windows 10 Home
    • バージョン 1909
    • ビルド 18363
  • その2

    • windows 10 Professional
    • バージョン 1903
    • ビルド 18362

以下の出力ログや実行結果は、環境その1でのものです。

WSL2インストールに関する参考情報

Windows 10 用 Windows Subsystem for Linux のインストール ガイド
Windows10でWSL2を使う

私の環境では、wsl --set-default-version 2は実行エラーがでますが、特に困らないので、このままにしています。

wsl --set-default-version 2の実行例
PS D:\dev> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

展開イメージのサービスと管理ツール
バージョン: 10.0.18362.900

イメージのバージョン: 10.0.18363.1082

機能を有効にしています
[==========================100.0%==========================]
操作は正常に完了しました。
PS D:\dev> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all

展開イメージのサービスと管理ツール
バージョン: 10.0.18362.900

イメージのバージョン: 10.0.18363.1082

機能を有効にしています
[==========================100.0%==========================]
操作は正常に完了しました。
PS D:\dev> wsl --set-default-version 2
WSL 2 を実行するには、カーネル コンポーネントの更新が必要です。詳細については https://aka.ms/wsl2kernel を参照してください
WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください

参考情報に沿って、Ubuntuまでインストールしました。

GDCインストールとお試し実行

以下の順にコマンドを実行して、GDC 10をインストールします。

GDCインストールコマンド
sudo apt update
sudo apt upgrade
sudo apt install gdc-10

参考までに実行ログを載せます。長いので折りたたんでいます。

user001@server001:~$ sudo apt update
[sudo] password for user001:
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Fetched 317 kB in 3s (110 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

user001@server001:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

user001@server001:~$ sudo apt install gdc-10
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu cpp-10 g++-10 gcc-10 libasan6 libatomic1 libbinutils libc-dev-bin
  libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libgcc-10-dev libgomp1 libgphobos-10-dev libgphobos1 libisl22
  libitm1 liblsan0 libmpc3 libquadmath0 libstdc++-10-dev libtsan0 libubsan1 linux-libc-dev manpages-dev zlib1g-dev
Suggested packages:
  binutils-doc gcc-10-locales g++-10-multilib gcc-10-doc gcc-10-multilib glibc-doc libstdc++-10-doc
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu cpp-10 g++-10 gcc-10 gdc-10 libasan6 libatomic1 libbinutils
  libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libgcc-10-dev libgomp1 libgphobos-10-dev
  libgphobos1 libisl22 libitm1 liblsan0 libmpc3 libquadmath0 libstdc++-10-dev libtsan0 libubsan1 linux-libc-dev
  manpages-dev zlib1g-dev
0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
Need to get 69.4 MB of archives.
After this operation, 355 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 binutils-common amd64 2.34-6ubuntu1 [207 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libbinutils amd64 2.34-6ubuntu1 [474 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 libctf-nobfd0 amd64 2.34-6ubuntu1 [47.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 libctf0 amd64 2.34-6ubuntu1 [46.6 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 binutils-x86-64-linux-gnu amd64 2.34-6ubuntu1 [1614 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 binutils amd64 2.34-6ubuntu1 [3376 B]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libisl22 amd64 0.22.1-1 [592 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libmpc3 amd64 1.1.0-1 [40.8 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/universe amd64 cpp-10 amd64 10-20200411-0ubuntu1 [8050 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 libcc1-0 amd64 10-20200411-0ubuntu1 [41.1 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 libgomp1 amd64 10-20200411-0ubuntu1 [101 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 libitm1 amd64 10-20200411-0ubuntu1 [26.3 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 libatomic1 amd64 10-20200411-0ubuntu1 [9284 B]
Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 libasan6 amd64 10-20200411-0ubuntu1 [344 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 liblsan0 amd64 10-20200411-0ubuntu1 [144 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal/main amd64 libtsan0 amd64 10-20200411-0ubuntu1 [319 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal/main amd64 libubsan1 amd64 10-20200411-0ubuntu1 [136 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal/main amd64 libquadmath0 amd64 10-20200411-0ubuntu1 [146 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal/main amd64 libgcc-10-dev amd64 10-20200411-0ubuntu1 [2340 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal/universe amd64 gcc-10 amd64 10-20200411-0ubuntu1 [16.3 MB]
Get:21 http://archive.ubuntu.com/ubuntu focal/main amd64 libc-dev-bin amd64 2.31-0ubuntu9 [71.8 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-45.49 [1137 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal/main amd64 libcrypt-dev amd64 1:4.4.10-10ubuntu4 [104 kB]
Get:24 http://archive.ubuntu.com/ubuntu focal/main amd64 libc6-dev amd64 2.31-0ubuntu9 [2520 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal/universe amd64 libstdc++-10-dev amd64 10-20200411-0ubuntu1 [1717 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal/universe amd64 g++-10 amd64 10-20200411-0ubuntu1 [9034 kB]
Get:27 http://archive.ubuntu.com/ubuntu focal/universe amd64 libgphobos1 amd64 10-20200411-0ubuntu1 [1385 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1 [156 kB]
Get:29 http://archive.ubuntu.com/ubuntu focal/universe amd64 libgphobos-10-dev amd64 10-20200411-0ubuntu1 [11.7 MB]
Get:30 http://archive.ubuntu.com/ubuntu focal/universe amd64 gdc-10 amd64 10-20200411-0ubuntu1 [8363 kB]
Get:31 http://archive.ubuntu.com/ubuntu focal/main amd64 manpages-dev all 5.05-1 [2266 kB]
Fetched 69.4 MB in 4min 22s (265 kB/s)
Extracting templates from packages: 100%
Selecting previously unselected package binutils-common:amd64.
(Reading database ... 31910 files and directories currently installed.)
Preparing to unpack .../00-binutils-common_2.34-6ubuntu1_amd64.deb ...
Unpacking binutils-common:amd64 (2.34-6ubuntu1) ...
Selecting previously unselected package libbinutils:amd64.
Preparing to unpack .../01-libbinutils_2.34-6ubuntu1_amd64.deb ...
Unpacking libbinutils:amd64 (2.34-6ubuntu1) ...
Selecting previously unselected package libctf-nobfd0:amd64.
Preparing to unpack .../02-libctf-nobfd0_2.34-6ubuntu1_amd64.deb ...
Unpacking libctf-nobfd0:amd64 (2.34-6ubuntu1) ...
Selecting previously unselected package libctf0:amd64.
Preparing to unpack .../03-libctf0_2.34-6ubuntu1_amd64.deb ...
Unpacking libctf0:amd64 (2.34-6ubuntu1) ...
Selecting previously unselected package binutils-x86-64-linux-gnu.
Preparing to unpack .../04-binutils-x86-64-linux-gnu_2.34-6ubuntu1_amd64.deb ...
Unpacking binutils-x86-64-linux-gnu (2.34-6ubuntu1) ...
Selecting previously unselected package binutils.
Preparing to unpack .../05-binutils_2.34-6ubuntu1_amd64.deb ...
Unpacking binutils (2.34-6ubuntu1) ...
Selecting previously unselected package libisl22:amd64.
Preparing to unpack .../06-libisl22_0.22.1-1_amd64.deb ...
Unpacking libisl22:amd64 (0.22.1-1) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../07-libmpc3_1.1.0-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.1.0-1) ...
Selecting previously unselected package cpp-10.
Preparing to unpack .../08-cpp-10_10-20200411-0ubuntu1_amd64.deb ...
Unpacking cpp-10 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libcc1-0:amd64.
Preparing to unpack .../09-libcc1-0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libcc1-0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../10-libgomp1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libgomp1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../11-libitm1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libitm1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../12-libatomic1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libatomic1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libasan6:amd64.
Preparing to unpack .../13-libasan6_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libasan6:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../14-liblsan0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking liblsan0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../15-libtsan0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libtsan0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libubsan1:amd64.
Preparing to unpack .../16-libubsan1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libubsan1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../17-libquadmath0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libquadmath0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libgcc-10-dev:amd64.
Preparing to unpack .../18-libgcc-10-dev_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libgcc-10-dev:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package gcc-10.
Preparing to unpack .../19-gcc-10_10-20200411-0ubuntu1_amd64.deb ...
Unpacking gcc-10 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../20-libc-dev-bin_2.31-0ubuntu9_amd64.deb ...
Unpacking libc-dev-bin (2.31-0ubuntu9) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../21-linux-libc-dev_5.4.0-45.49_amd64.deb ...
Unpacking linux-libc-dev:amd64 (5.4.0-45.49) ...
Selecting previously unselected package libcrypt-dev:amd64.
Preparing to unpack .../22-libcrypt-dev_1%3a4.4.10-10ubuntu4_amd64.deb ...
Unpacking libcrypt-dev:amd64 (1:4.4.10-10ubuntu4) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../23-libc6-dev_2.31-0ubuntu9_amd64.deb ...
Unpacking libc6-dev:amd64 (2.31-0ubuntu9) ...
Selecting previously unselected package libstdc++-10-dev:amd64.
Preparing to unpack .../24-libstdc++-10-dev_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libstdc++-10-dev:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package g++-10.
Preparing to unpack .../25-g++-10_10-20200411-0ubuntu1_amd64.deb ...
Unpacking g++-10 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libgphobos1:amd64.
Preparing to unpack .../26-libgphobos1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libgphobos1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../27-zlib1g-dev_1%3a1.2.11.dfsg-2ubuntu1_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.11.dfsg-2ubuntu1) ...
Selecting previously unselected package libgphobos-10-dev:amd64.
Preparing to unpack .../28-libgphobos-10-dev_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libgphobos-10-dev:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package gdc-10.
Preparing to unpack .../29-gdc-10_10-20200411-0ubuntu1_amd64.deb ...
Unpacking gdc-10 (10-20200411-0ubuntu1) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../30-manpages-dev_5.05-1_all.deb ...
Unpacking manpages-dev (5.05-1) ...
Setting up manpages-dev (5.05-1) ...
Setting up binutils-common:amd64 (2.34-6ubuntu1) ...
Setting up linux-libc-dev:amd64 (5.4.0-45.49) ...
Setting up libctf-nobfd0:amd64 (2.34-6ubuntu1) ...
Setting up libgomp1:amd64 (10-20200411-0ubuntu1) ...
Setting up libasan6:amd64 (10-20200411-0ubuntu1) ...
Setting up libgphobos1:amd64 (10-20200411-0ubuntu1) ...
Setting up libquadmath0:amd64 (10-20200411-0ubuntu1) ...
Setting up libmpc3:amd64 (1.1.0-1) ...
Setting up libatomic1:amd64 (10-20200411-0ubuntu1) ...
Setting up libubsan1:amd64 (10-20200411-0ubuntu1) ...
Setting up libcrypt-dev:amd64 (1:4.4.10-10ubuntu4) ...
Setting up libisl22:amd64 (0.22.1-1) ...
Setting up libbinutils:amd64 (2.34-6ubuntu1) ...
Setting up libc-dev-bin (2.31-0ubuntu9) ...
Setting up libcc1-0:amd64 (10-20200411-0ubuntu1) ...
Setting up liblsan0:amd64 (10-20200411-0ubuntu1) ...
Setting up cpp-10 (10-20200411-0ubuntu1) ...
Setting up libitm1:amd64 (10-20200411-0ubuntu1) ...
Setting up libtsan0:amd64 (10-20200411-0ubuntu1) ...
Setting up libctf0:amd64 (2.34-6ubuntu1) ...
Setting up libgcc-10-dev:amd64 (10-20200411-0ubuntu1) ...
Setting up libc6-dev:amd64 (2.31-0ubuntu9) ...
Setting up binutils-x86-64-linux-gnu (2.34-6ubuntu1) ...
Setting up libstdc++-10-dev:amd64 (10-20200411-0ubuntu1) ...
Setting up binutils (2.34-6ubuntu1) ...
Setting up gcc-10 (10-20200411-0ubuntu1) ...
Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-2ubuntu1) ...
Setting up g++-10 (10-20200411-0ubuntu1) ...
Setting up libgphobos-10-dev:amd64 (10-20200411-0ubuntu1) ...
Setting up gdc-10 (10-20200411-0ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

GDC 10を使ってコンパイルを試します。
コンパイラとバージョン情報を表示するプログラムとなります。

ver1.d
import std.stdio;

void main()
{
  writeln(__VENDOR__);
  writeln(__VERSION__);
}
実行結果
user001@server001:~$ which gdc-10
/usr/bin/gdc-10

user001@server001:~$ gdc-10 ver1.d

user001@server001:~$ ls
a.out  ver1.d

user001@server001:~$ ./a.out
GNU D
2076

Windows用にダウンロード可能なGDCのバイナリーバージョンは2.068.2なので、それよりも新しいバージョンである2.076が入手できました。

DMDインストールとお試し実行

引き続き、DMDをインストールします。
Ubuntuへのインストール方法は、DMD Downloadページに情報があるため、順番通りコマンドを実行します。

DMDインストールコマンド
sudo wget https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
sudo apt-get update --allow-insecure-repositories
sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring
sudo apt-get update && sudo apt-get install dmd-compiler dub

user001@server001:~$ sudo wget https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
[sudo] password for user001:
--2020-09-27 17:13:13--  https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list
Resolving netcologne.dl.sourceforge.net (netcologne.dl.sourceforge.net)... 78.35.24.46, 2001:4dd0:1234:6::5f
Connecting to netcologne.dl.sourceforge.net (netcologne.dl.sourceforge.net)|78.35.24.46|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://downloads.sourceforge.net/project/d-apt/files/d-apt.list?download&failedmirror=netcologne.dl.sourceforge.net [following]
--2020-09-27 17:13:15--  https://downloads.sourceforge.net/project/d-apt/files/d-apt.list?download&failedmirror=netcologne.dl.sourceforge.net
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.105.38.13
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.105.38.13|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://master.dl.sourceforge.net/project/d-apt/files/d-apt.list [following]
--2020-09-27 17:13:16--  https://master.dl.sourceforge.net/project/d-apt/files/d-apt.list
Resolving master.dl.sourceforge.net (master.dl.sourceforge.net)... 216.105.38.12
Connecting to master.dl.sourceforge.net (master.dl.sourceforge.net)|216.105.38.12|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 117 [application/octet-stream]
Saving to: ‘/etc/apt/sources.list.d/d-apt.list’

/etc/apt/sources.list.d/d-apt 100%[=================================================>]     117  --.-KB/s    in 0s

2020-09-27 17:13:16 (1.16 MB/s) - ‘/etc/apt/sources.list.d/d-apt.list’ saved [117/117]

user001@server001:~$ sudo apt-get update --allow-insecure-repositories
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Get:4 https://netcologne.dl.sourceforge.net/project/d-apt d-apt InRelease [5617 B]
Ign:4 https://netcologne.dl.sourceforge.net/project/d-apt d-apt InRelease
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:6 https://netcologne.dl.sourceforge.net/project/d-apt d-apt/main amd64 Packages [116 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [195 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [374 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [69.0 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [4696 B]
Get:11 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [38.4 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [9856 B]
Get:13 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [60.7 kB]
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [32.2 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [2544 B]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en [142 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [9828 B]
Get:18 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [43.6 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [10.8 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 c-n-f Metadata [352 B]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [170 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [90.1 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [5712 B]
Get:24 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [3088 B]
Get:25 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [224 B]
Fetched 1700 kB in 6s (267 kB/s)
Reading package lists... Done
W: GPG error: https://netcologne.dl.sourceforge.net/project/d-apt d-apt InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EBCF975E5BA24D5E
W: The repository 'https://netcologne.dl.sourceforge.net/project/d-apt d-apt InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

user001@server001:~$ sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  d-apt-keyring
0 upgraded, 1 newly installed, 0 to remove and 42 not upgraded.
Need to get 3354 B of archives.
After this operation, 14.3 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  d-apt-keyring
Authentication warning overridden.
Get:1 https://netcologne.dl.sourceforge.net/project/d-apt d-apt/main amd64 d-apt-keyring all 2012.02.19-3.1 [3354 B]
Fetched 3354 B in 3s (1250 B/s)
Selecting previously unselected package d-apt-keyring.
(Reading database ... 37698 files and directories currently installed.)
Preparing to unpack .../d-apt-keyring_2012.02.19-3.1_all.deb ...
Unpacking d-apt-keyring (2012.02.19-3.1) ...
Setting up d-apt-keyring (2012.02.19-3.1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package d-apt-keyring)
OK

user001@server001:~$ sudo apt-get update && sudo apt-get install dmd-compiler dub
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 https://netcologne.dl.sourceforge.net/project/d-apt d-apt InRelease [5617 B]
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Fetched 5617 B in 3s (1892 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  cpp cpp-9 gcc gcc-9 gcc-9-base libasan5 libdpkg-perl libfile-fcntllock-perl libgcc-9-dev libphobos2-94
  libphobos2-dev pkg-config
Suggested packages:
  cpp-doc gcc-9-locales dmd-doc dmd-tools gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc
  gcc-9-multilib gcc-9-doc debian-keyring bzr dpkg-dev
The following NEW packages will be installed:
  cpp cpp-9 dmd-compiler dub gcc gcc-9 gcc-9-base libasan5 libdpkg-perl libfile-fcntllock-perl libgcc-9-dev
  libphobos2-94 libphobos2-dev pkg-config
0 upgraded, 14 newly installed, 0 to remove and 42 not upgraded.
Need to get 29.6 MB of archives.
After this operation, 195 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 gcc-9-base amd64 9.3.0-10ubuntu2 [19.3 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 cpp-9 amd64 9.3.0-10ubuntu2 [7491 kB]
Get:3 https://netcologne.dl.sourceforge.net/project/d-apt d-apt/main amd64 libphobos2-94 amd64 2.094.0-0 [1377 kB]
Get:4 https://netcologne.dl.sourceforge.net/project/d-apt d-apt/main amd64 libphobos2-dev amd64 2.094.0-0 [4366 kB]
Get:5 https://netcologne.dl.sourceforge.net/project/d-apt d-apt/main amd64 dmd-compiler amd64 2.094.0-0 [2393 kB]
Get:6 https://netcologne.dl.sourceforge.net/project/d-apt d-apt/main amd64 dub amd64 1.23.0-0 [2590 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 cpp amd64 4:9.3.0-1ubuntu2 [27.6 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libdpkg-perl all 1.19.7ubuntu3 [230 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 pkg-config amd64 0.29.1-0ubuntu4 [45.5 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 libasan5 amd64 9.3.0-10ubuntu2 [395 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 libgcc-9-dev amd64 9.3.0-10ubuntu2 [2359 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 gcc-9 amd64 9.3.0-10ubuntu2 [8234 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 gcc amd64 4:9.3.0-1ubuntu2 [5208 B]
Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 libfile-fcntllock-perl amd64 0.22-3build4 [33.1 kB]
Fetched 29.6 MB in 1min 15s (392 kB/s)
Selecting previously unselected package gcc-9-base:amd64.
(Reading database ... 37702 files and directories currently installed.)
Preparing to unpack .../00-gcc-9-base_9.3.0-10ubuntu2_amd64.deb ...
Unpacking gcc-9-base:amd64 (9.3.0-10ubuntu2) ...
Selecting previously unselected package cpp-9.
Preparing to unpack .../01-cpp-9_9.3.0-10ubuntu2_amd64.deb ...
Unpacking cpp-9 (9.3.0-10ubuntu2) ...
Selecting previously unselected package cpp.
Preparing to unpack .../02-cpp_4%3a9.3.0-1ubuntu2_amd64.deb ...
Unpacking cpp (4:9.3.0-1ubuntu2) ...
Selecting previously unselected package libphobos2-94:amd64.
Preparing to unpack .../03-libphobos2-94_2.094.0-0_amd64.deb ...
Unpacking libphobos2-94:amd64 (2.094.0-0) ...
Selecting previously unselected package libdpkg-perl.
Preparing to unpack .../04-libdpkg-perl_1.19.7ubuntu3_all.deb ...
Unpacking libdpkg-perl (1.19.7ubuntu3) ...
Selecting previously unselected package pkg-config.
Preparing to unpack .../05-pkg-config_0.29.1-0ubuntu4_amd64.deb ...
Unpacking pkg-config (0.29.1-0ubuntu4) ...
Selecting previously unselected package libphobos2-dev:amd64.
Preparing to unpack .../06-libphobos2-dev_2.094.0-0_amd64.deb ...
Unpacking libphobos2-dev:amd64 (2.094.0-0) ...
Selecting previously unselected package libasan5:amd64.
Preparing to unpack .../07-libasan5_9.3.0-10ubuntu2_amd64.deb ...
Unpacking libasan5:amd64 (9.3.0-10ubuntu2) ...
Selecting previously unselected package libgcc-9-dev:amd64.
Preparing to unpack .../08-libgcc-9-dev_9.3.0-10ubuntu2_amd64.deb ...
Unpacking libgcc-9-dev:amd64 (9.3.0-10ubuntu2) ...
Selecting previously unselected package gcc-9.
Preparing to unpack .../09-gcc-9_9.3.0-10ubuntu2_amd64.deb ...
Unpacking gcc-9 (9.3.0-10ubuntu2) ...
Selecting previously unselected package gcc.
Preparing to unpack .../10-gcc_4%3a9.3.0-1ubuntu2_amd64.deb ...
Unpacking gcc (4:9.3.0-1ubuntu2) ...
Selecting previously unselected package dmd-compiler.
Preparing to unpack .../11-dmd-compiler_2.094.0-0_amd64.deb ...
Unpacking dmd-compiler (2.094.0-0) ...
Selecting previously unselected package dub.
Preparing to unpack .../12-dub_1.23.0-0_amd64.deb ...
Unpacking dub (1.23.0-0) ...
Selecting previously unselected package libfile-fcntllock-perl.
Preparing to unpack .../13-libfile-fcntllock-perl_0.22-3build4_amd64.deb ...
Unpacking libfile-fcntllock-perl (0.22-3build4) ...
Setting up libfile-fcntllock-perl (0.22-3build4) ...
Setting up libphobos2-94:amd64 (2.094.0-0) ...
Setting up dub (1.23.0-0) ...
Setting up libdpkg-perl (1.19.7ubuntu3) ...
Setting up gcc-9-base:amd64 (9.3.0-10ubuntu2) ...
Setting up libasan5:amd64 (9.3.0-10ubuntu2) ...
Setting up pkg-config (0.29.1-0ubuntu4) ...
Setting up cpp-9 (9.3.0-10ubuntu2) ...
Setting up libgcc-9-dev:amd64 (9.3.0-10ubuntu2) ...
Setting up cpp (4:9.3.0-1ubuntu2) ...
Setting up gcc-9 (9.3.0-10ubuntu2) ...
Setting up gcc (4:9.3.0-1ubuntu2) ...
Setting up libphobos2-dev:amd64 (2.094.0-0) ...
Setting up dmd-compiler (2.094.0-0) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for shared-mime-info (1.15-1) ...

DMDのインストールが完了したので、コンパイルしてみます。
先日リリースされた最新のバージョン2.094がインストールできました。

ver1.d
import std.stdio;

void main()
{
  writeln(__VENDOR__);
  writeln(__VERSION__);
}
実行結果
user001@server001:~$ which dmd
/usr/bin/dmd

user001@server001:~$ dmd ver1.d

user001@server001:~$ ls
a.out  ver1  ver1.d  ver1.o

user001@server001:~$ ./ver1
Digital Mars D
2094

LDCインストールとお試し実行

LDC – Installationのページを参考にLDCをインストールします。
インストール時のパッケージ名はldcですが、コンパイラのコマンドはldc2となります。

LDCインストールコマンド
sudo apt install ldc

user001@server001:~$ sudo apt install ldc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libphobos2-ldc-shared-dev libphobos2-ldc-shared90
The following NEW packages will be installed:
  ldc libphobos2-ldc-shared-dev libphobos2-ldc-shared90
0 upgraded, 3 newly installed, 0 to remove and 42 not upgraded.
Need to get 11.5 MB of archives.
After this operation, 86.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 libphobos2-ldc-shared90 amd64 1:1.20.1-1 [1215 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libphobos2-ldc-shared-dev amd64 1:1.20.1-1 [6262 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 ldc amd64 1:1.20.1-1 [4000 kB]
Fetched 11.5 MB in 44s (259 kB/s)
Selecting previously unselected package libphobos2-ldc-shared90:amd64.
(Reading database ... 38902 files and directories currently installed.)
Preparing to unpack .../libphobos2-ldc-shared90_1%3a1.20.1-1_amd64.deb ...
Unpacking libphobos2-ldc-shared90:amd64 (1:1.20.1-1) ...
Selecting previously unselected package libphobos2-ldc-shared-dev.
Preparing to unpack .../libphobos2-ldc-shared-dev_1%3a1.20.1-1_amd64.deb ...
Unpacking libphobos2-ldc-shared-dev (1:1.20.1-1) ...
Selecting previously unselected package ldc.
Preparing to unpack .../ldc_1%3a1.20.1-1_amd64.deb ...
Unpacking ldc (1:1.20.1-1) ...
Setting up libphobos2-ldc-shared90:amd64 (1:1.20.1-1) ...
Setting up libphobos2-ldc-shared-dev (1:1.20.1-1) ...
Setting up ldc (1:1.20.1-1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

ver1.d
import std.stdio;

void main()
{
  writeln(__VENDOR__);
  writeln(__VERSION__);
}
実行結果
user001@server001:~$ which ldc2
/usr/bin/ldc2

user001@server001:~$ ldc2 ver1.d

user001@server001:~$ ./ver1
LDC
2090

参考情報

Windows 10 用 Windows Subsystem for Linux のインストール ガイド
Windows10でWSL2を使う

aptコマンドチートシート

2
0
0

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
2
0