How to interact with DLL in R?

I created dll extensions from Matlab. Then, I want to read the dll in R.

I used dyn.load() , but it does not work.

Can you give me some suggestion?

+4
source share
3 answers

What language was the source code written in?

The problem is mixing compilers. The Matlab script was most likely created by Visual Studio. And you just can't mix C ++ code between different compilers, as function distortions get distorted. You can mix C. object code with some work. There are some FAQs on the MinGW website.

+2
source

Based on the discussion in the comment thread below @ Mario's answer: I was going to suggest you try the comparison you made ( R CMD SHLIB dll vs Matlab dll) to help diagnose the problem. Based on the results, I think that you need to find out what call syntax for the dll will be in C and write a small C-shell for it that uses this syntax, but, in turn, R CMD SHLIB -able ... R CMD SHLIB --help says that you can enable linker options on the command line (i.e. make sure that you link your DLL with Matlab-callable with your DLL-called DLL), but I'm not sure about the exact syntax. This will probably help to study a little the corresponding section of the R Extensions manual.

+1
source

Additional information required. The usual way to do this is as follows:

dyn.load ("/ path / to / library");

Some pointers:

  • make sure the library architecture is correct (for example, β€œx86_64” versus β€œi386” and β€œarmv7”)
  • make sure you are not trying to load Windows '.dll' on unix based machines ('.so', '.dylib')
0
source

All Articles