dreamer_999
dreamer_999

Reputation: 1525

Rlapack.dll is missing from your computer - c# and R

When I run a c# application through Visual Studio 2010, where R is integrated, I get the error: The program can't start because Rlapack.dll is missing from your computer. Try reinstalling the program to fix this problem. I tried reinstalling the program but it did not work. I also tried putting it in the folder that has the Matrix in it but it did not work. This solution was suggested in StackOverflow Q.

I am running 64-bit Windows 7! The application is 32-bit. There are two dll's. One in a folder called i386, and another one in the folder x64.

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RDotNet;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {



        public Form1()
        {
            InitializeComponent();
            string dlldir = @"D:\Program Files\R-2.15.0\bin\i386";

            bool r_located = false;


            while (r_located == false)
            {
                try
                {
                    REngine.SetDllDirectory(dlldir);
                    REngine.CreateInstance("RDotNet");
                    r_located = true;
                }

                catch
                {
                    MessageBox.Show(@"Unable to find R installation's \bin\i386 folder.
                    Press OK to attempt to locate it.");


                }
            }
        }
    }
}

Upvotes: 2

Views: 4518

Answers (3)

Austin
Austin

Reputation: 156

I realize this has been answered, but that was back in 2012. For anyone still having this problem with R version 3.4.3 or later in 2018, especially while trying to follow the simple example from the r.net home page, below is what I did to fix it:

  1. In your code, before the line REngine engine = REngine.GetInstance();, add this line REngine.SetEnvironmentVariables(@"C:\Program Files\R\R-3.4.3\bin\x64", @"C:\Program Files\R\R-3.4.3");.

  2. right click project, go to build and uncheck "Prefer 32-bit".

  3. copy Rlapack.dll from C:\Program Files\R\R-3.4.3\bin\i386

  4. paste in both C:\Program Files\R\R-3.4.3\library\stats\libs\i386 and C:\Program Files\R\R-3.4.3\library\Matrix\libs\i386

  5. copy Rlapack.dll from C:\Program Files\R\R-3.4.3\bin\x64

  6. paste in both C:\Program Files\R\R-3.4.3\library\stats\libs\x64 and C:\Program Files\R\R-3.4.3\library\Matrix\libs\x64.

Such a pain, but that is what finally got it to work for me.

Upvotes: 9

Daniel Bonetti
Daniel Bonetti

Reputation: 2416

Try setting path variable before caling the dll:

     var envPath = Environment.GetEnvironmentVariable("PATH");
     string s = null;
     if (Environment.Is64BitProcess)
         s = @"C:\Program Files\R\R-2.15.0\bin\x64";
     else
         s = @"C:\Program Files\R\R-2.15.0\bin\i386";
     Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + s);

Upvotes: 1

dreamer_999
dreamer_999

Reputation: 1525

Here is what I just did and it worked: I put the dll in the bin folder of my application.

Upvotes: 2

Related Questions