osx上的Mono似乎忽略了编译后的源文件中的#I

时间:2015-04-14 11:14:54

标签: macos dll path f# mono

我在OSX上与Fsharp和Mono的路径作斗争。我有两个问题:

  1. 有没有办法让单声道跟随Fsharp中的#I路径?
  2. 我是否可以在exe中包含dll,这样在一台机器上编译的文件可以在另一台机器上运行,而不必复制软件包的安装?
  3. 问题的示例如下:我已经使用nugget.exe将MathNet.Numerics安装在我的源目录上一层的“packages”本地目录中。运行示例:

    #I "../packages/MathNet.Numerics.3.6.0/lib/net40/"
    #r "MathNet.Numerics.dll"
    open MathNet.Numerics
    let v = SpecialFunctions.Gamma(0.5)
    printfn "%g" v
    

    后跟“;;”给出

    ...
    1.77245
    val v : float = 1.772453851
    val it : unit = ()
    

    虽然,当放在monoIgnoresPaths.fsx文件中时,我还要告诉mono,dll在哪里:

    Solsikke:src sporring$ mono --version
    Mono JIT compiler version 3.12.0 ((detached/a813491 Thu Dec 11 12:24:44 EST 2014)
    Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       altstack
        Notification:  kqueue
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug 
        LLVM:          yes(3.6.0svn-mono-(detached/5486eb2)
        GC:            sgen
    Solsikke:src sporring$ echo $MONO_PATH 
    
    Solsikke:src sporring$ fsharpc monoIgnoresPaths.fsx 
    F# Compiler for F# 3.1 (Open Source Edition)
    Freely distributed under the Apache 2.0 Open Source License
    Solsikke:src sporring$ mono monoIgnoresPaths.exe 
    
    Unhandled Exception:
    System.IO.FileNotFoundException: Could not load file or assembly 'MathNet.Numerics, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'MathNet.Numerics, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null'
    [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'MathNet.Numerics, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'MathNet.Numerics, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null'
    Solsikke:src sporring$ export MONO_PATH=`pwd`/../packages/MathNet.Numerics.3.6.0/lib/net40/;
    Solsikke:src sporring$ mono monoIgnoresPaths.exe 
    1.77245
    

    这是Mono中的错误吗?

    谢谢,乔恩

1 个答案:

答案 0 :(得分:1)

fsharpc忽略#I(按设计),该指令仅用于fsharpi

对于第二个问题,您可以使用--standalone将所有引用编译成二进制文件。