I would like to be able to run code written in F# on a linux system (Debian) but it's unlikely that I'll be able to install Mono on it. Is there any way to compile the F# to be fully static and have absolutely no dependencies on Mono? Basically just end up with an executable binary that I could run just like any other linux binary?
-
possible duplicate of [How to convert a simple .Net console project a into portable exe with Mono and mkbundle?](http://stackoverflow.com/questions/1321207/how-to-convert-a-simple-net-console-project-a-into-portable-exe-with-mono-and-mk) – skolima Sep 15 '11 at 20:39
2 Answers
Even on a stripped down account you can compile your own version of Mono - it is not particularly hard, see http://www.mono-project.com/Compiling_Mono. There are a few dependencies, but they aren't hard to find. You will need to prefix most of your run calls with mono though, like mono myapp.exe
rather than ./myapp.exe

- 25,356
- 3
- 48
- 67
Try AOT. But be ware of it's limitations.
Update:
I think I've jumped for an answer a bit too fast and haven't dive deep enough to turn it into something useful. AOT will pre-compile code into shared libraries, under the right conditions this may increase performance.
Still, if you have a requirement to not install the mono runtime in the client machine at all (why?), I think you should try mkbundle / mkbundle2. This will produce a huge self contained executable (C# Hello World + deps generated a file around 2.5MB for my machine... With -z I got around 900k). You can try to combine it with Linker to further strip out unused portions of libraries that your application depends on.
As for your second question F# compiler will generate CIL as any other .NET compiler. So, it should not matter. Still, if your application contains either IL instructions that are not yet supported by mono AOT compiler (e.g., you need mkbundle2 to handle generics) or dependencies to external linked libraries that you can't install in your Debian box you are out of lucky. Guess you will have to do a bit of trial and error operations by yourself.

- 21,918
- 9
- 70
- 118
-
I've looked at that but not sure I understand it. Keeps talking about "running" your program with mono... but I want to compile it and be able to just run it like normal. Also, will F# even work without JIT. – Adam Haile Sep 15 '11 at 18:55
-
@adam Here's something I don't understand. You have executable + write permissions to files (and presumably access to gcc) - why can't you just compile mono? – John Palmer Sep 16 '11 at 03:01
-
@jpalmer - I actually may be able to, but the admins of the system are picky, so I was just looking into my options. – Adam Haile Sep 16 '11 at 14:44