CentOs8に開発言語 nimをインストールしてHello Worldする

CentOs8に開発言語 nimをインストールしてHello Worldする

OSSの開発言語nimをcentos8にインストールしてHello Worldまでの環境構築手順

環境

  • OS  CentOS 8.0.1905 (Core)
  • nim Version 1.0.4

インストール

## インストール
curl https://nim-lang.org/choosenim/init.sh -sSf | sh

情報を提供するか質問されるがnで問題なかったです

choosenim-init: Downloading choosenim-0.4.0_linux_amd64
    Prompt: Can choosenim record and send anonymised telemetry data? [y/n]
        ... Anonymous aggregate user analytics allow us to prioritise
        ... fixes and features based on how, where and when people use Nim.
        ... For more details see: https://goo.gl/NzUEPf.

PATHを通します

export PATH=$HOME/.nimble/bin:$PATH

バージョンを確認

nim -v

<出力結果>
Nim Compiler Version 1.0.4 [Linux: amd64]
Compiled at 2019-11-27
Copyright (c) 2006-2019 by Andreas Rumpf

Hello Worldしてみる

hello.nimというファイルを下記のコードで作成します。

stdout.write("hello, world")

コンパイルして実行します

nim compile --run hello.nim

Hello Worldが表示されていることが確認できます。

Hint: used config file '/home/user/.choosenim/toolchains/nim-1.0.4/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: hello [Processing]
Hint:  [Link]
Hint: operation successful (14431 lines compiled; 0.200 sec total; 20.656MiB peakmem; Debug Build) [SuccessX]
Hint: /home/testuser/hello  [Exec]
hello, world

helloというバイナリも作成されます

./hello

<出力結果>
hello, world