On 21 March 2011 at 00:59, nandan amar wrote: | I was searching for SVN source link for rinside | I could only get tar.gz from | http://cran.r-project.org/web/packages/RInside/index.html | I placed the code as u did , but i got following error | | amar@amar:~/opt/RInside/inst/examples/standard$ make | R was not built as a library | R was not built as a library | g++ -I/usr/local/lib/R/site-library/Rcpp/include | -I"/usr/local/lib/R/site-library/RInside/include" -g -O2 -Wall | -I/usr/local/include amar.cpp -L/usr/local/lib/R/lib -lRblas | -L/usr/local/lib/R/lib -lRlapack | -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp | -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib | -L/usr/local/lib/R/site-library/RInside/lib -lRInside | -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -o amar | amar.cpp:1: fatal error: R.h: No such file or directory | compilation terminated. | make: *** [amar] Error 1 | | "R was not built as a library"..... I compiled and installed R-2.12.2 | as given in INSTALL | where am I going wrong. | Pls suggest
There are a couple of manuals that come with R which explain in great detail how to install R (as the error "R was not built as a library" is indicative of you not using a built where R is configured to be a shared library) and moreover R.h is not found --- but we cannot tell what you did wrong from the information you supplied. Somehow your system is non-standard and you will have to change that. Hope this helps, Dirk | regards. | | | On 18 March 2011 20:09, Dirk Eddelbuettel <[email protected]> wrote: | > | > On 18 March 2011 at 19:39, nandan amar wrote: | > | Dear All, | > | I am trying to use Some R api in c code. | > | To start with I copied following code and try to run as | > | | > | | > | a:~/Desktop/rcpp$ g++ file.cpp | > | | > | i got following error | > | | > | r.cpp:1: fatal error: R.h: No such file or directory | > | compilation terminated. | > | | > | How should I compile the code. | > | > Please look at the Makefile in the examples/standard/ directory of RInside. | > | > I just dropped your code as file 'amar.cpp' and said 'make'. Here is what | > happens: | > | > edd@max:~/svn/rinside/pkg/inst/examples/standard$ make | > g++ -I/usr/share/R/include -I/usr/local/lib/R/site-library/Rcpp/include -I"/usr/local/lib/R/site-library/RInside/include" -O3 -pipe -g -Wall amar.cpp -L/usr/lib64/R/lib -lR -lblas -llapack -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -L/usr/local/lib/R/site-library/RInside/lib -lRInside -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -o amar | > | > after which I can just say | > | > edd@max:~/svn/rinside/pkg/inst/examples/standard$ ./amar | > | > and the plot appears. You don't need the unlink(), R does that for you | > (which is why we use its tempfile() functions). | > | > Dirk | > | > | > | file.cpp | > | _____________________________________________________________ | > | #include <R.h> | > | //#include <Rinternals.h> | > | #include <RInside.h> // for the embedded R via RInside | > | using namespace std; | > | int main(int argc, char *argv[]) { | > | | > | // create an embedded R instance | > | RInside R(argc, argv); | > | | > | // evaluate an R expression with curve() | > | // because RInside defaults to interactive=false we use a file | > | std::string cmd = "tmpf <- tempfile('curve'); " | > | "png(tmpf); " | > | "curve(x^2, -10, 10, 200); " | > | "dev.off();" | > | "tmpf"; | > | // by running parseEval, we get the last assignment back, here the filename | > | std::string tmpfile = R.parseEval(cmd); | > | | > | std::cout << "Could now use plot in " << tmpfile << std::endl; | > | unlink(tmpfile.c_str()); // cleaning up | > | | > | // alternatively, by forcing a display we can plot to screen | > | cmd = "x11(); curve(x^2, -10, 10, 200); Sys.sleep(30);"; | > | // parseEvalQ evluates without assignment | > | R.parseEvalQ(cmd); | > | | > | exit(0); | > | } | > | | > | -- | > | Amar Kumar Nandan | > | _______________________________________________ | > | Rcpp-devel mailing list | > | [email protected] | > | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | > | > -- | > Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com | > | | | | -- | Amar Kumar Nandan | Karnataka, India, 560100 | http://aknandan.co.nr | -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
