开发者

How to compile a .fs file into a .exe?

I do no开发者_如何学Ct find a way to compile a simple file (.fs) to a .exe. I tried this example and it does not work:

  1. In the file dolphin.fs:

    let longBeaked = "Delphinus capensis"
    let shortBeaked = "Delphinus delphis"
    let dolphins = [ longBeaked; shortBeaked ]
    printfn "Known Dolphins: %A" dolphins
    
  2. You can now compile this code to an EXE as shown here:

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

But when I do this an error occurs on the ":" from "C:\fsharp"


This seems a bit wrong - aside from the fact that you're not supposed to type the first bit (as explained by svick), you probably also need to specify the full path to the F# compiler. If you're using F# that comes with Visual Studio 2010, then you need:

"C:\Program Files (x86)\Microsoft F#\v4.0\Fsc.exe" dolphins.fs

If you're using standalone installation of F#, then you'll need to locate the F# compiler somewhere else (probably in "Program Files (x86)\FSharp-2.0.0.0", but I'm not exactly sure). Also, I'm not sure what is the dir command supposed to do. To execute the compiled application (once it is compiled), you can just type:

doplhins.exe


You're not supposed to type the whole line. The C:\fsharp> part represents the command line prompt. You should just type fsc dolhins.fs and then dir dolphins.exe.


The error messages sound like you're typing command-prompt commands into F# interactive.

Try opening the "Visual Studio Command Prompt" from your start menu, changing to the right directory, and typing your commands there.

Alternately, create a new F# Application project in Visual Studio, add your .fs file to the project, and build it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜