How to compile .fs file in .exe?

I did not find a way to compile a simple file (.fs) in .exe. I tried this example and it does not work:

  • In the dolphin.fs file:

    let longBeaked = "Delphinus capensis" let shortBeaked = "Delphinus delphis" let dolphins = [ longBeaked; shortBeaked ] printfn "Known Dolphins: %A" dolphins 
  • Now you can compile this code in EXE, as shown below:

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

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

+4
compiler-construction f #
source share
3 answers

This seems a bit wrong - besides the fact that you should not enter the first bit (as explained by svick), you probably also need to specify the full path to the F # compiler. If you are using F #, which comes with Visual Studio 2010, you need to:

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

If you are using a standalone installation of F #, you need to find the F # compiler somewhere else (perhaps in "Program Files (x86) \ FSharp-2.0.0.0", but I'm not quite sure), Also, I'm not sure what the dir command should do. To execute the compiled application (after compiling it), you can simply enter:

 doplhins.exe 
+3
source share

You do not have to enter the entire string. Part C:\fsharp> represents a command prompt. You should just type fsc dolhins.fs and then dir dolphins.exe .

+3
source share

The error messages sound like you are entering command line commands in F # interactive.

Try opening the Visual Studio Command Prompt in the Start menu by changing the correct directory and typing your commands there.

Alternatively, create a new F # application project in Visual Studio, add the .fs file to the project, and create it.

+1
source share

All Articles