Rocky Linux 9にプログラム言語Nimをインストールする
環境
OSバージョンを確認します
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)
操作方法
1.gccをインストールします
# sudo dnf install gcc
gccバージョンを確認します
# gcc --version gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2.Nimをインストールします
# curl https://nim-lang.org/choosenim/init.sh -sSf | sh インストール途中、「Answer」欄に「n」を選択してます。 略 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を通します
# echo 'export PATH=/root/.nimble/bin:$PATH' >> ~/.bash_profile
設定を反映します
# exec $SHELL -l
4.nimのバージョンを確認します
# nim -v Nim Compiler Version 1.6.8 [Linux: amd64] Compiled at 2022-09-27 Copyright (c) 2006-2021 by Andreas Rumpf git hash: c9f46ca8c9eeca8b5f68591b1abe14b962f80a4c active boot switches: -d:release
5.動作確認
# nano hello.nim
以下のコードを記述します
stdout.write("hello, world study nim arkgame")
ファイルをコンパイルして実行します
# nim compile --run hello.nim Hint: used config file '/root/.choosenim/toolchains/nim-1.6.8/config/nim.cfg' [Conf] Hint: used config file '/root/.choosenim/toolchains/nim-1.6.8/config/config.nims' [Conf] ......................................................... CC: ../../root/.choosenim/toolchains/nim-1.6.8/lib/std/private/digitsutils.nim CC: ../../root/.choosenim/toolchains/nim-1.6.8/lib/system/dollars.nim CC: ../../root/.choosenim/toolchains/nim-1.6.8/lib/system/io.nim CC: ../../root/.choosenim/toolchains/nim-1.6.8/lib/system.nim CC: hello.nim Hint: [Link] Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code) 26691 lines; 2.216s; 31.598MiB peakmem; proj: /home/ark/hello.nim; out: /home/ark/hello [SuccessX] Hint: /home/ark/hello [Exec]
コンパイルして実行します
# ./hello hello, world study nim arkgame