Question

I am trying to build R (tried 2.14.2 and 2.15) and rpy2 (2.2.6, python 2.7.1) on ubuntu (11.04, natty narwhal), to deploy it to a custom directory (in the following called /home/me/lib/R), since I do not have root access, but need a newer version than available on the server.

Details of build etc further down, but even when running the tests of rpy2, I always get the following error:

/home/me/lib/pythonlib/lib/python/rpy2/rinterface/__init__.py in <module>()
---> 87 from rpy2.rinterface._rinterface import *
ImportError: libRblas.so: cannot open shared object file: No such file or directory
WARNING: Failure executing file: <experiments/arrangement/test_smacof_arrange.py>

I am sure I am calling the right rpy2 module (my custom built one) which has been built against custom built R version. To do this I am doing the following:

  1. I first Build R-base on ubuntu

    wget http://cran.r-project.org/bin/linux/ubuntu/natty/r-base_2.14.2.orig.tar.gz
    # untar and go to directory
    
    # enable-R-shblib flag is needed for rpy2 linking, enable-BLAS-shlib was included
    # because I hoped to solve the problem, which doesnt change anything however
    ./configure --enable-R-shlib --enable-BLAS-shlib --prefix=/home/me/lib/R
    make
    make install
    
  2. I then build rpy2 against this R build

    wget http://pypi.python.org/packages/source/r/rpy2/rpy2-2.2.6.tar.gz
    # untar and go to directory
    
    # build rpy2, by providing the r-home-lib and r-home flags, and deploy to custom dir
    python setup.py build --r-home /home/me/lib/R --r-home-lib /home/me/lib/R/lib64/R/lib install --home /home/me/lib/pythonlib
    

    I also have adapted my pythonpath to find modules in /home/me/lib/pythonlib, so the problem isn't there. The python build returns the correct configuration (note that Rblas appears here!)

    Configuration for R as a library:
    include_dirs: ('/home/me/lib/R/lib64/R/include',)
    libraries: ('R', 'Rblas', 'Rlapack')
    library_dirs: ('/home/me/lib/R/lib64/R/lib',)
    extra_link_args: ()
    

I have tried to track down the error, but to no end. /home/me/lib/R/lib64/R/lib contains libRblas.so, but there is one thing which seems strange however, which is that libRblas.so is not linked correctly from libR.so, but I am not sure wether this causes the error, nor do I know how to fix it.

>> ldd -d libR.so

linux-vdso.so.1 =>  (0x00007fffcec58000)
libRblas.so => not found
libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007fe63d21d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe63cf97000)
...

Any help would be greatly appreciated!

Was it helpful?

Solution

For others running into this issue, I was able to solve it by making sure to add the R libraries to my library path in bashrc:

export LD_LIBRARY_PATH="R-install-location/lib65/R/lib:$LD_LIBRARY_PATH"

OTHER TIPS

Briefly:

  1. Why build R on Ubuntu? Just grab the existing and current binaries from the CRAN repo as per the README at http://cran.r-project.org/bin/linux/ubuntu -- these are ports of the current Debian packages made available via CRAN to overcome the normal Ubuntu publishing lag.

  2. Whenever I need a newer (small) package on Ubuntu, I just grab the Debian package sources and rebuild those on Ubuntu. There should be ample HOWTO on the net on how to build a package; the minimum is to a) down the triplet .orig.tar.gz, .diff.gz and .dsc and use dpkg-sourcepackage -x *.dsc to expand and then b) change into the directory and run sudo debian/rules binary (provided you have all Build-Depends: packages installed). You can even use apt-get to do these steps for you but it is getting a little beyond the scope of this question...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top