1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macOS に Mono をインストールして F# を CLI からコンパイルして実行する

Last updated at Posted at 2020-07-24

『プログラミング F#』を読み始めて、macOS で F# を CLI からコンパイルする方法に戸惑ったので、Mono を使用してコンパイルする方法をメモっておく。

『プログラミング F#』の Hello World が CLI からコンパイルできないってことで調べたわけなんだけど、プロジェクトを作成した後にビルドして実行するとか、F# スクリプトとして実行するとか、F# インタプリタで実行するとかであれば、Use F# on macOSを参考にするといいかも。

Mono をインストールする

Homebrew を最新にしてから Mono をインストールする。

$ brew update
$ brew install mono

HelloWorld.fs をコンパイルする

『プログラミング F#』にある Hello World をコンパイルしてみる。Homebrew でインストールした Mono では fscfsharpc になるみたい。ちなみに、fsifsharpi になるっぽい。

$ cat << EOS >> HelloWorld.fs
// HelloWorld.fs

printfn "Hello, World"
EOS
$ fsharpc HelloWorld.fs

コンパイルがうまくいくと、HelloWorld.exe ができあがる。

HelloWorld.exe を実行する

HelloWorld.exe を Mono で実行する。./HelloWorld.exe として実行できないことに注意する。

$ mono HelloWorld.exe
Hello, World

参考文献

プログラミング F#
https://fsharp.org/use/mac/

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?