Ivan Krylov
2023-Aug-30 18:59 UTC
[R] Problems with installing R packages from source and running C++ in R, even on fresh R installation
On Wed, 30 Aug 2023 16:31:20 +0000 Christophe Bousquet <chr_bousquet at protonmail.com> wrote:> So, yes, it seems possible for R to localize paths related to > Rtools... But then, I really do not get where things go wrong...When installing packages containing code to compile, R eventually calls R CMD SHLIB. Same thing happens with inline C++: it gets stored in a temporary file, compiled into a *.dll using R CMD SHLIB and then loaded using dyn.load(). Write the following into a file named hello.c: #include <R.h> #include <Rinternals.h> SEXP hello(void) { SEXP ret = PROTECT(allocVector(STRSXP, 1)); SET_STRING_ELT(ret, 0, mkChar("hello")); UNPROTECT(1); return ret; } From within R, setwd() to the directory containing hello.c and run: tools::Rcmd('SHLIB -n hello.c') tools::Rcmd('SHLIB hello.c') What do the commands print? Does the second command fail? (Let's Cc: R-help at r-project.org in case people with more experience debugging Windows problems have a better idea what's going on.) -- Best regards, Ivan
Duncan Murdoch
2023-Aug-30 19:10 UTC
[R] Problems with installing R packages from source and running C++ in R, even on fresh R installation
On 30/08/2023 2:59 p.m., Ivan Krylov wrote:> On Wed, 30 Aug 2023 16:31:20 +0000 > Christophe Bousquet <chr_bousquet at protonmail.com> wrote: > >> So, yes, it seems possible for R to localize paths related to >> Rtools... But then, I really do not get where things go wrong... > > When installing packages containing code to compile, R eventually calls > R CMD SHLIB. Same thing happens with inline C++: it gets stored in a > temporary file, compiled into a *.dll using R CMD SHLIB and then loaded > using dyn.load(). > > Write the following into a file named hello.c: > > #include <R.h> > #include <Rinternals.h> > SEXP hello(void) { > SEXP ret = PROTECT(allocVector(STRSXP, 1)); > SET_STRING_ELT(ret, 0, mkChar("hello")); > UNPROTECT(1); > return ret; > } > > From within R, setwd() to the directory containing hello.c and run: > > tools::Rcmd('SHLIB -n hello.c') > tools::Rcmd('SHLIB hello.c') > > What do the commands print? Does the second command fail? > > (Let's Cc: R-help at r-project.org in case people with more experience > debugging Windows problems have a better idea what's going on.) >It sounds exactly as though Rtools files aren't on the path that's in effect when R starts. That's probably the one stored in the registry. In the old days it was set in the System app in the Windows Control Panel under "Edit the system environment variables". I don't know if that's still true. Duncan Murdoch
Apparently Analagous Threads
- Problems with installing R packages from source and running C++ in R, even on fresh R installation
- Problems with installing R packages from source and running C++ in R, even on fresh R installation
- Problems with installing R packages from source and running C++ in R, even on fresh R installation
- Problems with installing R packages from source and running C++ in R, even on fresh R installation
- Problems with installing R packages from source and running C++ in R, even on fresh R installation