Ubuntu 22.04 LTSにプログラミング言語nimをインストールする方法
環境
OSバージョンの確認
# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
nimのインストール手順
1.依存パッケージをインストールします
# sudo apt install curl build-essential
2.curlコマンドでnimをインストールします
# curl https://nim-lang.org/choosenim/init.sh -sSf | sh choosenim-init: Downloading choosenim-0.8.2_linux_amd64 Info: Version 1.6.6 already selected choosenim-init: ChooseNim installed in /root/.nimble/bin choosenim-init: You must now ensure that the Nimble bin dir is in your PATH. choosenim-init: Place the following line in the ~/.profile or ~/.bashrc file. choosenim-init: export PATH=/root/.nimble/bin:$PATH
3.PATHを設定します
# nano ~/.profile
追記
export PATH=/root/.nimble/bin:$PATH
設定を反映します
# source ~/.profile
4.nimバージョンを確認します
# nim -v Nim Compiler Version 1.6.6 [Linux: amd64] Compiled at 2022-05-05 Copyright (c) 2006-2021 by Andreas Rumpf git hash: 0565a70eab02122ce278b98181c7d1170870865c active boot switches: -d:release
5.動作確認
# nano test.nim
以下の内容を編集します
echo “study skill become smart hello world"
「test.nim」をコンパイルします
# nim c test.nim Hint: used config file '/root/.choosenim/toolchains/nim-1.6.6/config/nim.cfg' [Conf] Hint: used config file '/root/.choosenim/toolchains/nim-1.6.6/config/config.nims' [Conf] ......................................................... CC: stdlib_digitsutils.nim CC: stdlib_dollars.nim CC: stdlib_io.nim CC: stdlib_system.nim CC: test.nim Hint: [Link] Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code) 26670 lines; 4.108s; 31.578MiB peakmem; proj: /root/test.nim; out: /root/test [SuccessX]
コンパイルしたファイルを実行します
# ./test study skill become smart hello world