[R-sig-Debian] RInside

Paul Johnson pauljohn32 at gmail.com
Mon Jul 19 06:43:44 CEST 2010


On Mon, Jul 12, 2010 at 12:40 PM, David Rosengarten
<save.of.ten at gmail.com> wrote:
> Yes, I have R and r-base-dev installed, and I just did this yesterday so I
> am working with the newest versions of everything.  The commands that run
> when I say 'make' in that directory are:

Hello, David:

I never tried RInside before, but after your post I became curious.  I
checked your first message, it does not say if you installed R from
the standard packages.  I think *how* R is built can have a big
effect. The instructions on RInstall say you must have R installed as
a shared library in order for this to work.  Do you have a file
libR.so?  (If not, then you don't) Here's what I have on Ubuntu.

$ ls -la /usr/lib64/R/lib
total 3376
drwxr-xr-x 2 root root    4096 2010-07-18 19:59 .
drwxr-xr-x 8 root root    4096 2010-06-07 11:55 ..
lrwxrwxrwx 1 root root      36 2010-07-18 19:56 libblas.so ->
/usr/lib64/libgoto2_penrynp-r1.13.so
-rw-r--r-- 1 root root  442200 2009-09-14 21:08 libguide.so
lrwxrwxrwx 1 root root      31 2010-07-18 19:59 liblapack.so ->
/usr/lib/atlas/liblapack.so.3gf
-rw-r--r-- 1 root root 3004504 2010-06-06 21:10 libR.so

If your system doesn't have libR.so, there's no happiness in your
future. Also, I notice that I have a symbolic link from that libR.so
to /usr/lib64, and if you don't have that, I expect you are in
trouble:

$ ls -la /usr/lib64/libR.so
lrwxrwxrwx 1 root root 13 2010-07-18 23:03 /usr/lib64/libR.so -> R/lib/libR.so

It is possible to build R without using the shared library. In fact,
that is the default.  As far as I know, there may be some performance
advantage in NOT having libR.so. R Install manual footnote p. 38:

" We have measured 15–20% on ‘i686’ Linux and around 10% on ‘x86_64’ Linux."

RInside wants it.

But I am sure that Dirk's packages for R for Ubuntu do have the
configure line set to create an R shared library.

For me, RInside installed cleanly, but I ran into some trouble
compiling the examples.  I had been fiddling around building shared
libRblas.so and changing to the GOTOBLAS2 shared blas, and I think
that confused the RInside example at runtime.

./rinside_sample3
./rinside_sample3: error while loading shared libraries: libblas.so:
cannot open shared object file: No such file or directory

That made me think that I needed to erase /usr/lib64/R/lib altogether,
make sure all that fiddling around I did was removed, and reinstall
r-base-core, r-base-dev, and the revolution-mkl package (because I
have been interested in the Intel Kernel Math library lately).  After
that, I check to see where R's executable is looking for stuff

$ ldd /usr/lib64/R/bin/exec/R
        linux-vdso.so.1 =>  (0x00007fff19fff000)
        libR.so => /usr/lib/libR.so (0x00007f27542ed000)
        libc.so.6 => /lib/libc.so.6 (0x00007f2753f6a000)
        libblas.so.3gf => /usr/lib/atlas/libblas.so.3gf (0x00007f27535ce000)
        libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0x00007f27532e1000)
        libm.so.6 => /lib/libm.so.6 (0x00007f275305e000)
        libreadline.so.6 => /lib/libreadline.so.6 (0x00007f2752e1c000)
        libpcre.so.3 => /lib/libpcre.so.3 (0x00007f2752bee000)
        libbz2.so.1.0 => /lib/libbz2.so.1.0 (0x00007f27529dd000)
        libz.so.1 => /lib/libz.so.1 (0x00007f27527c5000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f27525c1000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f275488e000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f27523aa000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00007f2752166000)

Well, it is not pointing at the Intel math libraries.  Maybe that's a
good thing. I believe R is compiled against atlas, and it may be that
substituting the shared blas or lapack was causing trouble. I'll have
to try to track that down later.

Anyway, after putting R back the way nature intended, now the RInside
example does run.

Observe:

pauljohn at pols124:standard$ ./rinside_sample0
Hello, world!
pauljohn at pols124:standard$ ./rinside_sample1
Running ls()
[1] "argv" "M"
Showing M
     [,1] [,2] [,3] [,4]
[1,]    0    1    2    3
[2,]   10   11   12   13
[3,]   20   21   22   23
[4,]   30   31   32   33
Showing colSums()
[1] 60 64 68 72
In C++ element 0 is 60
In C++ element 1 is 64
In C++ element 2 is 68
In C++ element 3 is 72

I'll let you know if I get to the bottom of the runtime "can't find
libblas.so" error I got before.


Oh, in case you wondered, when I compiled the example code before
reinstalling the R packages, I got the same kind of output you got
from make in the examples folder. So, clearly, being able to make the
example does not imply that the compiled example will run.

pauljohn at pols124:standard$ make
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample0.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample0
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample1.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample1
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample2.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample2
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample3.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample3
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample4.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample4
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample5.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample5
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample6.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample6
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample7.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample7
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_sample8.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_sample8
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_test0.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_test0
g++ -I/usr/share/R/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/include
-I/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib -g -O2
-Wall  -s  rinside_test1.cpp  -L/usr/lib64/R/lib -lR -lblas -llapack
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib -lRcpp
-Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/Rcpp/lib
-L/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-lRInside -Wl,-rpath,/home/pauljohn/R/x86_64-pc-linux-gnu-library/2.11/RInside/lib
-o rinside_test1
pauljohn at pols124:standard$

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas



More information about the R-SIG-Debian mailing list