I do not find documents on the command line for compiling a F# source and then run it on a Mac OS. Here is what I tried, which did not work.
First, I have a lexer specification file "ExprLex_hj.fsl". I generated the lexer using a strange command line which I took from a website:
mono ~/.nuget/packages/fslexyacc/10.0.0/build/fslex/net46/fslex.exe --unicode ExprLex_hj.fsl
The line above produces a file named "ExprLex_hj.fs". Then I compiled that f# file with another strange command line I copied from another website
fsharpc -r ~/.nuget/packages/fslexyacc/10.0.0/build/fsyacc/net46/FsLexYacc.Runtime.dll ExprLex_hj.fs
This line above produces an EXE file on my Mac OS, ExprLex_hj.exe
.
Now I need to run this EXE file. I heard that we could do it with mono, an open source implementation of Microsoft's .NET Framework. So, I tried
mono ExprLex_hj.exe
Boom! I got an error:
Unhandled Exception: System.BadImageFormatException: Could not resolve field token 0x04000008, due to: Could not load type of field '<StartupCode$ExprLex_hj>.$ExprLex:_fslex_tables@24' (2) due to: Could not load file or assembly 'FsLexYacc.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:/Users/zell/test_lexer_fsharp/ExprLex_hj.exe type:$ExprLex member:(null)
Can you tell me how to solve this issue? The thing is few documentation can be found on how to run an executable generated from a F# source file. Most tutorials suggest to use .FSX or run a f# file on REPL, which is not what I want -- I would like to execute the generated binary from the command line.
Besides, on my machine, I have Visual Studio installed but I still need to know the command line way to execute an EXE. Also, after installing Visual Studio, I got "fshapri", "fsharpc", "mono", and "dotnet" in my PATH. I am actually unsure whether I should use "mono" or "dotnet" to run an EXE in this situation.