安裝 F# 3.0(Linux)

黃志斌發表於2013-04-15

安裝 Mono 3.0

在 Linux 中從 Git Hub 安裝 Mono 3.0:

$ cd ~/repo
$ git clone git://github.com/mono/mono.git
正克隆到 'mono'...
remote: Counting objects: 904690, done.
remote: Compressing objects: 100% (145374/145374), done.
remote: Total 904690 (delta 761387), reused 898930 (delta 756444)
接收物件中: 100% (904690/904690), 191.12 MiB | 24 KiB/s, done.
處理 delta 中: 100% (761387/761387), done.
Checking out files: 100% (44735/44735), done.
$ cd mono
$ ./autogen.sh --prefix=/usr/local

  ......

        mcs source:    mcs

   Engine:
    GC:           sgen and bundled Boehm GC with typed GC and parallel mark
    TLS:           __thread
    SIGALTSTACK:   yes
    Engine:        Building and using the JIT
    oprofile:      no
    BigArrays:     no
    DTrace:        no
    LLVM Back End: no (dynamically loaded: no)

   Libraries:
    .NET 2.0/3.5:  yes
    .NET 4.0:      yes
    .NET 4.5:      yes
    MonoDroid:     no
    MonoTouch:     no
    JNI support:   IKVM Native
    libgdiplus:    assumed to be installed
    zlib:          system zlib


Now type `make' to compile

$ make
$ sudo make install
$ sudo ln -s /usr/lib/libgdiplus.so /usr/local/lib/libgdiplus.so

安裝結果

$ mono --version
Mono JIT compiler version 3.0.10 (master/eff4cb5 2013年 04月 15日 星期一 18:46:05 CST)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            Included Boehm (with typed GC and Parallel Mark)
$ dmcs --version
Mono C# compiler version 3.0.10.0

安裝 F# 3.0

$ cd ~/repo
$ git clone https://github.com/fsharp/fsharp
正克隆到 'fsharp'...
remote: Counting objects: 4916, done.
remote: Compressing objects: 100% (1784/1784), done.
remote: Total 4916 (delta 3565), reused 4326 (delta 3023)
接收物件中: 100% (4916/4916), 33.68 MiB | 18 KiB/s, done.
處理 delta 中: 100% (3565/3565), done.
$ cd fsharp
$ ./autogen.sh
$ make
$ sudo make install
$ sudo gacutil -i lib/release/4.0/FSharp.Core.dll
Installed lib/release/4.0/FSharp.Core.dll into the gac (/usr/local/lib/mono/gac)

安裝結果

執行 F# 互動環境(fsharpi):

$ fsharpi

F# Interactive for F# 3.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

For help type #help;;

> System.Environment.Version.ToString();;
val it : string = "4.0.30319.17020"
> System.Environment.OSVersion.ToString();;
val it : string = "Unix 3.8.6.1"
> #quit;;

- Exit...

還有 F# 編譯器(fsharpc):

$ cat Test.fs
let dt = System.DateTime(1582, 10, 4)
printfn "%s" (dt.ToString("dddd yyyy-MM-dd"))
printfn "%s" (dt.AddDays(1.0).ToString("dddd yyyy-MM-dd"))
$ fsharpc Test.fs
F# Compiler for F# 3.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
$ mono Test.exe
星期一 1582-10-04
星期二 1582-10-05

參考資料

  1. The F# Software Foundation
  2. F# Compiler (open source edition) @ github
  3. fshap/fsharp · GitHub
  4. mono/mono · GitHub

相關文章