0

Possible Duplicate:
Problem with compiling RInside examples under Windows

On Windows XP:

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
> 

I attempted to compile the simplest program written by Dirk:

#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);
}

The environment variable PATH in all contains this:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\R\batchfiles_0.6-6;C:\R\Rtools\bin;C:\R\Rtools\MinGW\bin;C:\Program Files\GnuWin32;C:\"Program Files"\R\R-2.15.1\;

I copied this Makefile from a existing R example of RInside in Windows XP.

## -*- mode: make; tab-width: 8; -*-
##
## Simple Makefile
##
## TODO: 
##  proper configure for non-Debian file locations,   [ Done ]
##  allow RHOME to be set for non-default R etc

## comment this out if you need a different version of R, 
## and set set R_HOME accordingly as an environment variable
R_HOME :=       C:\"Program Files"\R\R-2.15.1\

sources :=      $(wildcard *.cpp)
programs :=         $(sources:.cpp=)


## include headers and libraries for R 
RCPPFLAGS :=        $(shell $(R_HOME)/bin/R CMD config --cppflags)
RLDFLAGS :=         $(shell $(R_HOME)/bin/R CMD config --ldflags)
RBLAS :=        $(shell $(R_HOME)/bin/R CMD config BLAS_LIBS)
RLAPACK :=      $(shell $(R_HOME)/bin/R CMD config LAPACK_LIBS)

## if you need to set an rpath to R itself, also uncomment
#RRPATH :=      -Wl,-rpath,$(R_HOME)/lib

## include headers and libraries for Rcpp interface classes
RCPPINCL :=         $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RCPPLIBS :=         $(shell echo 'Rcpp:::LdFlags()'  | $(R_HOME)/bin/R --vanilla --slave)


## include headers and libraries for RInside embedding classes
RINSIDEINCL :=      $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RINSIDELIBS :=      $(shell echo 'RInside:::LdFlags()'  | $(R_HOME)/bin/R --vanilla --slave)

## compiler etc settings used in default make rules
CXX :=          $(shell $(R_HOME)/bin/R CMD config CXX)
CPPFLAGS :=         -Wall $(shell $(R_HOME)/bin/R CMD config CPPFLAGS)
CXXFLAGS :=         $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R CMD config CXXFLAGS)
LDLIBS :=       $(RLDFLAGS) $(RRPATH) $(RBLAS) $(RLAPACK) $(RCPPLIBS) $(RINSIDELIBS)

all:            $(programs)
            @test -x /usr/bin/strip && strip $^

run:            $(programs)
            @for p in $(programs); do echo; echo "Running $$p:"; ./$$p; done

clean:
            rm -vf $(programs)
            rm -vrf *.dSYM

runAll:
            for p in $(programs); do echo "Running $$p"; ./$$p; done

This is my R folder in C drive: enter image description here

I saw this thread but I don't have anything like site-library in the R folder.

I changed the R_HOME to C:\"Program Files"\R\R-2.15.1, that resulted in the following errors:

enter image description here

Community
  • 1
  • 1
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

2 Answers2

3

It fails because you installed R in C:\Program Files\R even though the FAQ for R on Windows tells you not to install R in a path with spaces. See "Question 2.2: How do I install R for Windows":

If you want to be able to build packages from sources, we recommend that you choose an installation path not containing spaces.

The Rcpp / RInside documentaion repeats that recommendation. Do not install R in a path with spaces. If you must, you have to fix the Makefile to avoid the path expansion from breaking.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • and I am thankful to you for dealing with this basic question. – Aquarius_Girl Oct 17 '12 at 13:05
  • Dirk, now that you are here, i would like to confirm that the RInside now "does" run on Windows without a segmentation fault? You said `RInside 0.2.5, on CRAN as of today, restores the Windows functionality--using the fix James notes in the other comment.` in the other thread. This does mean that the seg fault problem is now completely solved? – Aquarius_Girl Oct 17 '12 at 13:08
  • 1
    Yes, as stated repeatedly here, on my blog, evidenced by the CRAN tests and autobuilders, by the R-Forge autobuilders, lots of users on list, and here, ... – Dirk Eddelbuettel Oct 17 '12 at 13:24
  • I checked your blog of RInside but perhaps missed the information. Thankful to btw. – Aquarius_Girl Oct 17 '12 at 13:40
  • "It fails because you installed R in C:\Program Files\R even though the FAQ for R on Windows tells you not to install R in a path with spaces. See "Question 2.2: How do I install R for Windows":" why not put the onus on the installer rather than buried in a document telling the user they need to modify their default installation. That's literally buried somewhere and without knowing what to look for, no one would find it unless pointed out (I too am having compiling woes atm and am reading up) – thistleknot Oct 22 '19 at 00:29
1

Your path are totally wrong for me: why you use C:\R\Rtools\bin as R_HOME if your R main path is simply C:\R ? If your R folder is what you've shown in the screenshot, BTW, also your classpath is totally wrong!

Vincenzo Maggio
  • 3,787
  • 26
  • 42
  • My fault, I did not know what I was doing here. Wait, I'll just try that and see what happens. – Aquarius_Girl Oct 17 '12 at 07:11
  • Change also the windows PATH and ask your collegue for the correct file paths! – Vincenzo Maggio Oct 17 '12 at 07:12
  • That didn't help much, again resulted in some errors. I'll post the screenshot. – Aquarius_Girl Oct 17 '12 at 07:12
  • `BTW, also your classpath is totally wrong!` Please tell how do I find the correct path. There is no one here who can help me. – Aquarius_Girl Oct 17 '12 at 07:18
  • I have added the screenshot again. – Aquarius_Girl Oct 17 '12 at 07:43
  • Yes but your problem is the same: you have to change the makefile and the PATH environment variable to reflect the directories of your existing installation! – Vincenzo Maggio Oct 17 '12 at 08:19
  • Yes, that path environ variable, I haven't changed that yet. Wait I'll do it. – Aquarius_Girl Oct 17 '12 at 08:20
  • Now, I have changed the makefile, path var, and the screenshots too. The R was probably installed in the "Program Files" folder. I am still facing errors. Please help. – Aquarius_Girl Oct 17 '12 at 08:32
  • First try: change in the makefile the line "R_HOME := C:\"Program Files"\R\R-2.15.1\" in R_HOME := C:/"Program Files"/R/R-2.15.1". And I think you should use = and not :=. See this: http://scite-ru.googlecode.com/svn/trunk/lualib/luacom/Makefile.win – Vincenzo Maggio Oct 17 '12 at 09:07
  • Putting "" the way you said resulted in error: `"C:\"Program`" is not recognized a s an external..`. Replacing := with = did not change anything. One more thing I'd like to tell you is that the makefile that I am using has been copied from the "standard/examples" folder of R in Windows. Is there anything else that I can do here? – Aquarius_Girl Oct 17 '12 at 11:02