Windows Subsystem for Linux(WSL)でmakeを方法です!
makeはデフォルトで入ってない
とりあえずmakeを叩いてみました。
するとパッケージが入ってなかったようで、こんなメッセージが出ました。
$ make The program 'make' can be found in the following packages: * make * make-guile Try: sudo apt install <selected package>
必要なパッケージをインストール
ということで、この2つのコマンドを叩いて、makeを使えるようにする。
- sudo apt install make
- sudo apt install make-guile
アウトプット結果を表示
$ sudo apt install make [sudo] password for user: Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: make The following NEW packages will be installed: guile-2.0-libs libgc1c2 libltdl7 libunistring0 make-guile 0 upgraded, 5 newly installed, 1 to remove and 137 not upgraded. Need to get 2,791 kB of archives. After this operation, 12.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libunistring0 amd64 0.9.3-5.2ubuntu1 [279 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgc1c2 amd64 1:7.4.2-7.3ubuntu0.1 [82.1 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libltdl7 amd64 2.4.6-0.1 [38.3 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 guile-2.0-libs amd64 2.0.11+1-10 [2,239 kB] Get:5 http://archive.ubuntu.com/ubuntu xenial/universe amd64 make-guile amd64 4.1-6 [152 kB] Fetched 2,791 kB in 17s (158 kB/s) (Reading database ... 31972 files and directories currently installed.) Removing make (4.1-6) ... Processing triggers for man-db (2.7.5-1) ... Selecting previously unselected package libunistring0:amd64. (Reading database ... 31956 files and directories currently installed.) Preparing to unpack .../libunistring0_0.9.3-5.2ubuntu1_amd64.deb ... Unpacking libunistring0:amd64 (0.9.3-5.2ubuntu1) ... Selecting previously unselected package libgc1c2:amd64. Preparing to unpack .../libgc1c2_1%3a7.4.2-7.3ubuntu0.1_amd64.deb ... Unpacking libgc1c2:amd64 (1:7.4.2-7.3ubuntu0.1) ... Selecting previously unselected package libltdl7:amd64. Preparing to unpack .../libltdl7_2.4.6-0.1_amd64.deb ... Unpacking libltdl7:amd64 (2.4.6-0.1) ... Selecting previously unselected package guile-2.0-libs:amd64. Preparing to unpack .../guile-2.0-libs_2.0.11+1-10_amd64.deb ... Unpacking guile-2.0-libs:amd64 (2.0.11+1-10) ... Selecting previously unselected package make-guile. Preparing to unpack .../make-guile_4.1-6_amd64.deb ... Unpacking make-guile (4.1-6) ... Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for man-db (2.7.5-1) ... Setting up libunistring0:amd64 (0.9.3-5.2ubuntu1) ... Setting up libgc1c2:amd64 (1:7.4.2-7.3ubuntu0.1) ... Setting up libltdl7:amd64 (2.4.6-0.1) ... Setting up guile-2.0-libs:amd64 (2.0.11+1-10) ... Setting up make-guile (4.1-6) ... Processing triggers for libc-bin (2.23-0ubuntu9) ...
これでOK!
makeが使えるようになります!
簡単なMakefile
ごくごく簡単なMakefileの書き方です。
変数的なものを使ったりして、もっとスマートに書く方法があるようですが……
test: test.c gcc -o test.exe test.c
インデントの文字は「タブ文字」ですよ!
これで
make
と実行すれば、コンパイルが通れば、「test.c」から「test.exe」が作られます。
Makefileは空白文字に注意!
ちなみにMakefileのインデント文字は、タブでないといけないようです。
実はMakefile初めてだったので躓きました……