Chaitanya Nettem
Chaitanya Nettem

Reputation: 1239

installing windows only R packages in Ubuntu

I have a R package that i need to use. The package in question is BQuant.

The package is downloadable as a zip file which (I found out later) contains windows binaries. First I tried to extract these binaries and pack it in .tar.gz And i installed the .tar.gz package using install.packages().

This didn't give any error but when i tried to call any function of the package R gave me the error: Error: could not find function <function_name>.

So then i found the source files and tried extracting and repacking in .tar.gz. This time, during the installation the error was: **ERROR: Windows-only package**

When i checked the description in the source files it said OS_type: windows. I removed that line and tried again. This time the error was:

gcc -std=gnu99 -shared -o BQuant.so dp.o -L/usr/lib/R/lib -lR
dp.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make:  ***[BQuant.so] Error 1
ERROR: compilation failed for package ‘BQuant’

So in brief: I need to know whether this windows package can be installed in Linux.

Upvotes: 1

Views: 619

Answers (2)

Mischa Vreeburg
Mischa Vreeburg

Reputation: 1586

I think you need to change a bit in the 'BQuant\R\fcn_preproc.r' file.

This file loads the dll file, which is a windows only file.

.First.lib <- function(lib, pkg) 
{
   library.dynam("BQuant.dll")
}

You might try to add a test based on platform.

.First.lib <- function(lib, pkg) 
{
   if(.Platform$OS.type == 'windows'){
      library.dynam("BQuant.dll")
   }
   if(.Platform$OS.type == 'unix'){
      library.dynam("BQuant.so")
   }
}

This might do the trick. Also don't forget to change the os line the dependent file.

To try to compile the .c file, you can use this command from terminal.

R CMD SHLIB -o BQuant.so dc.c

As per : http://www.ats.ucla.edu/stat/r/library/interface.pdf and http://www.maths.lancs.ac.uk/~prangle/CinR/CinR.pdf

Upvotes: 3

Gavin Simpson
Gavin Simpson

Reputation: 174778

As far as I can see there is no compiled code object for unix/linux. The zip you link to really is just a windows binary and is missing the sources that you would need to compile into the equivalent of BQuant.dll on linux. Even the R code is in "compiled" form, i.e. not plain text R code.

Unless you have the source code then you won't be able to compile this to work on Linux. Ontact the maintainer to see if they can provide a proper source package.

Upvotes: 2

Related Questions