0

可能重复:
在 Windows 下编译 RInside 示例时出现问题

在 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     
> 

我尝试编译 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);
}

环境变量 PATH 全部包含以下内容:
%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\;

我从 Windows XP 中 RInside 的现有 R 示例中复制了这个 Makefile。

## -*- 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

这是我在 C 盘中的 R 文件夹: 在此处输入图像描述

我看到了这个线程site-library,但我在 R 文件夹中没有类似的东西。

我将 更改R_HOMEC:\"Program Files"\R\R-2.15.1,导致以下错误:

在此处输入图像描述

4

2 回答 2

3

它失败了,因为您安装了 R,C:\Program Files\R即使Windows 上 R 的常见问题解答告诉您不要将 R 安装在带有空格的路径中。请参阅“问题 2.2:如何为 Windows 安装 R”:

如果您希望能够从源代码构建包,我们建议您选择不包含空格的安装路径。

Rcpp / RInside 文档重复了该建议。不要将 R 安装在带有空格的路径中。 如果必须,您必须修复 Makefile 以避免路径扩展中断。

于 2012-10-17T12:27:50.827 回答
1

你的路径对我来说是完全错误的:为什么你使用你的 R 主路径是简单C:\R\Rtools\bin的?如果您的 R 文件夹是您在屏幕截图中显示的内容,顺便说一句,您的类路径也是完全错误的!R_HOMEC:\R

于 2012-10-17T07:09:47.303 回答