This project is read-only.

unable to load DLL 'libdl.dll'

Jul 29, 2013 at 6:26 PM
Hi - I've very new to R.Net (and programming in general) so forgive me if this is a newbie questions. I installed R.Net from Nuget (version 1.5.1) and am trying to run a simple console app based on the examples given. I'm receiving this error on this line of code:
         Unable to load DLL libdl.dll

          using (REngine engine = REngine.CreateInstance("RDotNet"))

Where does this dll come from - what do I do to get it installed/recognized?

Jul 30, 2013 at 1:44 AM
Sorry, I mistook to upload the Unix version assembly.
I reupload the correct (Windows) version.
Please update the NuGet package by "Manage NuGet Packages..." -> "Updates" (you will get
Jul 30, 2013 at 1:10 PM
Hi, Thanks for your reply.

I updated the NuGet package and now I am getting an error 'DLL not found' - but, it's not telling me which DLL it's looking for - Here is the stacktrace:

at RDotNet.NativeLibrary.UnmanagedDll..ctor(String dllName)
at RDotNet.REngine..ctor(String id, String dll)
at RDotNet.REngine.CreateInstance(String id, String dll)
at RDotNetConsole.Program.Main(String[] args) in c:\TFSCloudSourceCode\POCCode\RDotNetConsole\RDotNetConsole\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Jul 30, 2013 at 11:18 PM

Given the stacktrace, this is very likely because R.dll is not found, because is its directory is not in the PATH environmental variable. It sounds however like you started from the examples and would have picked up the need to update the PATH. Next thing to look at is if you are trying to load 32 bit R.dll from a 64 bit process or vice-versa.

I was thinking of looking at adding some code to R.NET to automate the discovery of this library location information. Base case is easy, but it is trickier than it sounds, because subject to a lot of potential odd machine specific behaviors. I'll have a look in a few days.
Jul 31, 2013 at 5:04 PM
Hi there,

Thanks for your reply. I did update the PATH environemnt variable and even added this to my code as a precaution:
I am running it from a 64-bit machine - so is that the issue? How do I download a 64-bit version of the software?

Jul 31, 2013 at 11:55 PM
Edited Jul 31, 2013 at 11:56 PM
SetDllDirectory is deprecated. If you are using the same directory for adding to PATH as you use for SetDllDirectory, this does not look right either. What is needed is the path to the native R.dll library that comes with the R program. The R.NET home page has a clear example.

Depending on your project 'RDotNetConsole' you need to specify, for instance:
"c:\Program Files\R\R-3.0.1\bin\i386"
"c:\Program Files\R\R-3.0.1\bin\x64"

See for instance /platform (C# Compiler Options) and linked pages for an explanations with .NET processes.

R.NET is built as AnyCPU, and will work with either 32 or 64 bits processes.

Aug 1, 2013 at 6:20 PM
I didn't realize I needed to install the original R software as well as R.Net. Once I did that and set my path environment to find the R.dll, everything worked fine.

Thanks again for your help!