Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compiler construction 如何将.fs文件编译成.exe?_Compiler Construction_F# - Fatal编程技术网

Compiler construction 如何将.fs文件编译成.exe?

Compiler construction 如何将.fs文件编译成.exe?,compiler-construction,f#,Compiler Construction,F#,我找不到将简单文件(.fs)编译为.exe的方法。我尝试了这个示例,但它不起作用: 在dolphin.fs文件中: let longBeaked = "Delphinus capensis" let shortBeaked = "Delphinus delphis" let dolphins = [ longBeaked; shortBeaked ] printfn "Known Dolphins: %A" dolphins 您现在可以将此代码编译为EXE,如下所示: C:\fsharp&g

我找不到将简单文件(.fs)编译为.exe的方法。我尝试了这个示例,但它不起作用:

  • 在dolphin.fs文件中:

    let longBeaked = "Delphinus capensis"
    let shortBeaked = "Delphinus delphis"
    let dolphins = [ longBeaked; shortBeaked ]
    printfn "Known Dolphins: %A" dolphins
    
  • 您现在可以将此代码编译为EXE,如下所示:

    C:\fsharp> fsc dolphins.fs
    C:\fsharp> dir dolphins.exe
    

  • 但是当我这样做时,在“:”from“C:\fsharp”

    上会出现一个错误,您不应该键入整行。
    C:\fsharp>
    部分表示命令行提示符。您只需键入
    fsc dolhins.fs
    ,然后键入
    dir dolphins.exe
    这似乎有点错误-除了您不应该键入第一位之外(如svick所解释的),您可能还需要指定F编译器的完整路径。如果您使用的是Visual Studio 2010附带的F#,那么您需要:

    "C:\Program Files (x86)\Microsoft F#\v4.0\Fsc.exe" dolphins.fs
    
    如果您使用的是F#的独立安装,那么您需要在其他地方找到F#编译器(可能在“Program Files(x86)\FSharp-2.0.0.0”中,但我不太确定)。另外,我不确定
    dir
    命令应该做什么。要执行已编译的应用程序(编译后),只需键入:

    doplhins.exe
    

    错误消息听起来像是在F#interactive中键入命令提示符命令

    尝试从“开始”菜单打开“Visual Studio命令提示符”,切换到正确的目录,然后在那里键入命令


    或者,在Visual Studio中创建一个新的F#应用程序项目,将.fs文件添加到该项目中,然后构建它。

    ?您从何处调用fsc?C:\Program Files(x86)\Microsoft F#\v4.0\fsc.exe dolphins.fs返回“意外字符”\'”C:\Program Files(x86)\Microsoft F#\v4.0\fsc.exe“dolphins.fs返回”此值不是函数,无法应用“PS:我正在使用Visual Studio”2010@katter75“值”不是一个函数“错误来自F#编译器,因此这是一个很好的起点。看起来您的文件中可能有一些意外的空白或类似的内容。你能检查源代码并发布完整的错误消息吗?@katter75-你报告的错误消息听起来像是在F#interactive中键入命令行。您需要在命令提示符下键入这些内容,或者在Visual Studio中创建和F#Windows应用程序项目并简单地构建它。当我只键入“fsc dolphins.fs”时,会出现以下错误:未定义值或构造函数“fsc”。您应该将其写入Windows命令行。如果您使用的是VS,您只需使用它的Build命令,它就会自动创建exe文件,无需手动调用
    fsc