Hi List, I find the following .so file in the R folder of my Arch Linux machine: ,---------------------- | usr/lib/R/lib/libR.so `---------------------- I copied it to my home folder and changed permissons from root to my personal user and then tried to call R functions from a different language (that has a 'native' function to call any kind of Shared Library on Linux). But to no avail - no matter if I try to call 'help' or 'imax2', I'm always told the function doesn't exist. So my question is basically: whats in there in the libR.so? Can't I call all core R functions (via 'native') with the same arguments as on the R command line? I'm a bit confused now about how to use R as a shared library on Linux. Thanks for any tips. -- cheers, Thorsten
Using R as Shared Library
5 messages · Thorsten Jolitz, R. Michael Weylandt, Dirk Eddelbuettel
Thorsten Jolitz <tjolitz at googlemail.com> writes: Let me reformulate my question (since I managed to make 'native' calls to C functions in libR by now): I still wonder whats 'in there' in libR - only the core C functions, or all the functions written in R itself too? And what packages are included?
cheers, Thorsten
On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz <tjolitz at googlemail.com> wrote:
Thorsten Jolitz <tjolitz at googlemail.com> writes: Let me reformulate my question (since I managed to make 'native' calls to C functions in libR by now): I still wonder whats 'in there' in libR - only the core C functions, or all the functions written in R itself too? And what packages are included?
Just C functions.
-- cheers, Thorsten
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 12 August 2012 at 07:56, Michael Weylandt wrote:
| On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz <tjolitz at googlemail.com> wrote:
| > Thorsten Jolitz <tjolitz at googlemail.com> writes:
| > Let me reformulate my question (since I managed to make 'native' calls
| > to C functions in libR by now):
| > I still wonder whats 'in there' in libR - only the core C functions, or
| > all the functions written in R itself too? And what packages are included?
|
| Just C functions.
Moreover, many of these are marked 'non visible' and cannot be accessed. You
probably want to consider
a) the standalone R math library, available eg on Debian/Ubuntu as package
r-mathlib which gets you a subset of R (distribution functions, random
numbers, ...) for use in other programs, or
b) the embedding API of R
Both of these are documented in the 'Writing R Extension' manual that came
with R.
If you are interested in b), you may also want to look at the RInside project
which makes embedding a lot easier. The simplest example is just
#include <RInside.h> // for the embedded R via RInside
int main(int argc, char *argv[]) {
RInside R(argc, argv); // create an embedded R instance
R["txt"] = "Hello, world!\n"; // assign a char* (string) to 'txt'
R.parseEvalQ("cat(txt)"); // eval the init string, ignoring any returns
exit(0);
}
which passes a string to the embedded R interpreter and calls an R function
to display it. You can send full R objects back and forth thanks to Rcpp, and
there are over a dozen examples included in the packages, as well as more
advanced use of embedded R within the context of MPI (for parallel
computing), Qt (for GUIs and much more) or Wt (for web applications).
Cheers, Dirk
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Dirk Eddelbuettel <edd at debian.org> writes:
On 12 August 2012 at 07:56, Michael Weylandt wrote:
| On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz
| <tjolitz at googlemail.com> wrote:
| > Thorsten Jolitz <tjolitz at googlemail.com> writes:
| > Let me reformulate my question (since I managed to make 'native' calls
| > to C functions in libR by now):
| > I still wonder whats 'in there' in libR - only the core C functions, or
| > all the functions written in R itself too? And what packages are
| > included?
|
| Just C functions.
Moreover, many of these are marked 'non visible' and cannot be accessed. You
probably want to consider
a) the standalone R math library, available eg on Debian/Ubuntu as package
r-mathlib which gets you a subset of R (distribution functions, random
numbers, ...) for use in other programs, or
b) the embedding API of R
Both of these are documented in the 'Writing R Extension' manual that came
with R.
If you are interested in b), you may also want to look at the RInside project
which makes embedding a lot easier. The simplest example is just
#include <RInside.h> // for the embedded R via RInside
int main(int argc, char *argv[]) {
RInside R(argc, argv); // create an embedded R instance
R["txt"] = "Hello, world!\n"; // assign a char* (string) to 'txt'
R.parseEvalQ("cat(txt)"); // eval the init string, ignoring any returns
exit(0);
}
which passes a string to the embedded R interpreter and calls an R function
to display it. You can send full R objects back and forth thanks to Rcpp, and
there are over a dozen examples included in the packages, as well as more
advanced use of embedded R within the context of MPI (for parallel
computing), Qt (for GUIs and much more) or Wt (for web applications).
Thanks, that looks very interesting indeed.
cheers, Thorsten