I have a very basic C# console application on macOS with the code pasted below. When I try to run this code, the call to REngine.GetInstance() fails with the following exception:
Unhandled exception. System.ArgumentException: This 64-bit process failed to load the library libR.dylib. No further error message from the dynamic library loader
at DynamicInterop.UnmanagedDll.ThrowFailedLibraryLoad(String dllFullName, String nativeError)
at DynamicInterop.UnmanagedDll.ReportLoadLibError(String dllName, String nativeError)
at DynamicInterop.UnmanagedDll..ctor(String dllName)
at RDotNet.REngine..ctor(String id, String dll)
at RDotNet.REngine.CreateInstance(String id, String dll)
at RDotNet.REngine.GetInstance(String dll, Boolean initialize, StartupParameter parameter, ICharacterDevice device)
at RTest.Program.Main(String[] args) in /Users/.../Projects/RTest/RTest/Program.cs:line 14
I have made sure that there are no multiple R installations on the system. Also, tried to execute the same code on the M1 machine as well as on Intel-based Mac.
Here is the code:
using System;
using RDotNet;
namespace RTest
{
class Program
{
static void Main(string[] args)
{
var e = REngine.GetInstance();
e.Initialize();
}
}
}
I have also tried explicitly specifying R_HOME and R_PATH using REngine.SetEnvironmentVariables(rPath: "/usr/local/Cellar/r/4.1.2_1/lib/R/lib", rHome: "/usr/local/Cellar/r/4.1.2_1"); but to no avail.
Any help will be highly appreciated.
Thanks