I want to use Mpir.NET with F# (4.5) on Ubuntu 18.04, using dotnet on the command line. Not successful. If there is an easier way to use Mpir.NET on F# linux, please advise.
Followed dotnet instructions at https://learn.microsoft.com/en-us/dotnet/fsharp/get-started/get-started-command-line. The example project using the Newtonsoft.Json package worked fine When I build a project to test Mpir.NET, I get an error as described below.
dotnet new sln -o MpirProj
dotnet new console -lang F# -o src/App
replaced src/App/Program.fs with program from Mpir.NET documentation:
open Mpir.NET
let a = 756749075976907490175905790287846502134Z
let b = 529134916478965674697197076070175107505Z
let c = a*b
printfn "%O" c
dotnet add src/App/App.fsproj package Mpir.NET
I get the following info/warn message:
warn : Package 'Mpir.NET 0.4.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. info : Package 'Mpir.NET' is compatible with all the specified frameworks in project 'src/App/App.fsproj'. info : PackageReference for package 'Mpir.NET' version '0.4.0' added to file '/home/doug/f#favs/MpirProj/src/App/App.fsproj'.
dotnet sln add src/App/App.fsproj
the resulting App.fsproj file is :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Mpir.NET" Version="0.4.0" />
</ItemGroup>
</Project>
do the build
dotnet build
messages
/home/doug/f#favs/MpirProj/src/App/App.fsproj : warning NU1701: Package 'Mpir.NET 0.4.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. App -> /home/doug/f#favs/MpirProj/src/App/bin/Debug/netcoreapp2.1/App.dll
Build succeeded.
When I run, see error messages below
~/f#favs/MpirProj/src/App$ dotnet run
messages
/home/doug/f#favs/MpirProj/src/App/App.fsproj : warning NU1701: Package 'Mpir.NET 0.4.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. /home/doug/f#favs/MpirProj/src/App/App.fsproj : warning NU1701: Package 'Mpir.NET 0.4.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.
Unhandled Exception: System.TypeInitializationException: The type initializer for 'Mpir.NET.mpir' threw an exception. ---> System.Exception: MPIR: can't determine path to the xmpir.so at Mpir.NET.mpir.LocateLibrary(String name) at Mpir.NET.mpir.GetXMPIRLibraryPath() at Mpir.NET.mpir.initialize_hxmpir() at Mpir.NET.mpir..cctor() --- End of inner exception stack trace --- at Mpir.NET.mpir.mpz_init_set_str(String str, UInt32 _base) at Mpir.NET.NumericLiteralZ.FromString(String s) at .$Program.main@() in /home/doug/f#favs/MpirProj/src/App/Program.fs:line 3