I have a .NET project written in C# that has a dependency with the CoolProp library (available here https://github.com/CoolProp/CoolProp). It calls the CoolProp functions using PInvoke.
Unluckily I have to run this program in a linux environment (precisely the AWS lambda env https://docs.aws.amazon.com/en_us/lambda/latest/dg/current-supported-versions.html).
For now, I want to execute it with .NET core (command dotnet run
) on my PC with Ubuntu OS but I get always the following error:
Unhandled Exception: System.DllNotFoundException:
Unable to load shared library 'libCoolProp.so' or one of its dependencies.
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibCoolProp.so.so: cannot open shared object file: No such file or directory
at Test1.Program.PropsSI(String Output, String Name1, Double Prop1, String Name2, Double Prop2, String Ref)
at Test1.Program.Main(String[] args) in /home/user/Desktop/TestDllInUbuntu/Test1/Program.cs:line 23
The test program is:
using System;
using System.Runtime.InteropServices;
namespace Test1
{
class Program
{
[DllImport("libCoolProp.so")]
private static extern double PropsSI(string Output, string Name1, double Prop1, string Name2, double Prop2, string Ref);
static void Main(string[] args)
{
double propsRes = PropsSI("H", "T", 300.0, "Q", 0.0, "R410A");
Console.WriteLine(propsRes);
}
}
}
The Program.cs
is in the same folder of libCoolProp.so
.
Notes:
- The same program in Windows 10 compiled and executed with .Net Core with its
libCoolProp.dll
works. - The same program in Ubuntu 18 compiled and executed with Mono Runtime works.
How to solve the compatibility issue between CoolProp lib and .Net Core runtime?