views:

74

answers:

1

I need arbitrary precision rational numbers, which I'm given to understand are available in the F# powerpack. My question is about the mechanics of distribution; my program needs to be able to compile and run both on Windows/.Net and Linux/Mono at least, since I have potential users on both platforms. As I understand it, the best procedure is:

  1. Download the powerpack .zip, not the installer.

  2. Copy the DLL into my program directory.

  3. Copy the accompanying license file into my program directory, to make sure everything is above board.

  4. Declare references and go ahead and use the functions I need.

  5. Ship the above files along with my source and binary, and since the DLL uses byte code, it will work fine on any platform.

Is this the correct procedure? Am I missing anything?

+2  A: 

You're essentially correct, arbitrary precision rational numbers are available only in PowerPack (BigInteger is part of .NET 4.0, but rationals are still F# specific).

However, you'll also need to distribute your program with F# runtime redistributable (that is the FSharp.Core.dll assembly). It contains some basic F# types (such as types used to represent functions) that are not a part of standard .NET runtime.

When you add a reference to your project, the compiler includes the name and version of the referenced library in your application. When the application starts, the runtime tries to locate the library in various places. So, to deploy your application on both .NET and Mono, you'll need to (somehow) distribute your application together with FSharp.Core.dll and FSharp.PowerPack.dll.

  • The F# Redistributable and F# PowerPack installers place the library to GAC (Global Assembly Cache) which is shared by all .NET apps on the computer. On Mono, you can get the same result by using the gacutil tool (from command line). In that case, you need to copy them somewhere (anywhere) and run this tool. Your application will find them in the GAC.

  • Alternatively, if you place the assemblies to the same folder as your application (exe file) then both .NET and Mono should locate them correctly as well and it should work. I believe that this is discouraged for versioning reasons (e.g. the globally installed file can be easily updated), but I don't think the license prohibits this form of deployment.

It seems that for creating .NET/Mono redistributable, using the second technique would be easier (as it allows simple xcopy depoloyment).

Tomas Petricek
What about the --standalone option, would that be a bad idea?
Benjol
@Benjol: Good point! `--standalone` option compiles all referenced libraries into the produced assembly (so the assembly alone should work on a plain platform). It is a bit "inelegant" and it won't work if your program consists of multiple assemblies, but for single-assembly projects, it should be fine.
Tomas Petricek