在Windows下编译RInside示例的问题

时间:2011-04-13 13:29:36

标签: c++ r makefile rinside

我正在尝试在我们被迫使用Windows环境的地方设置RInside。

我已安装RTools并下载了RInside binary from CRAN

我的R安装位于 c:\ R \ R-2.12.2 中,因此带有空格的文件夹没有问题。

我在 R 中安装了 Rcpp RInside 软件包。

我执行下载的 RInside 二进制文件中包含的以下makefile Makefile.win

## -*- mode: makefile; 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 :=       'cygdrive/c/R/R-2.12.2'

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)

## 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)
LDFLAGS =       -s
LDLIBS :=       $(RLDFLAGS) $(RBLAS) $(RLAPACK) $(RINSIDELIBS) $(RCPPLIBS) 
CC :=           $(shell $(R_HOME)/bin/R CMD config CXX)

all :           $(programs)

clean:
        rm -vf $(programs)

使用命令

make -f Makefile.win

尝试构建包含的标准示例

但是,我收到以下错误:

C:\RInside_0.2.3\RInside\examples\standard>make -f Makefile.win
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
cygdrive/c/R/R-2.12.2/bin/R: not found
cygdrive/c/R/R-2.12.2/bin/R: not found
cygdrive/c/R/R-2.12.2/bin/R: not found
cygdrive/c/R/R-2.12.2/bin/R: not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
make: cygdrive/c/R/R-2.12.2/bin/R: Command not found
Wall  -s  rinside_callbacks0.cpp        -o rinside_callbacks0
make: Wall: Command not found
make: [rinside_callbacks0] Error 127 (ignored)
Wall  -s  rinside_module_sample0.cpp        -o rinside_module_sample0
make: Wall: Command not found
make: [rinside_module_sample0] Error 127 (ignored)
Wall  -s  rinside_sample0.cpp        -o rinside_sample0
make: Wall: Command not found
make: [rinside_sample0] Error 127 (ignored)
Wall  -s  rinside_sample1.cpp        -o rinside_sample1
make: Wall: Command not found
make: [rinside_sample1] Error 127 (ignored)
Wall  -s  rinside_sample2.cpp        -o rinside_sample2
make: Wall: Command not found
make: [rinside_sample2] Error 127 (ignored)
Wall  -s  rinside_sample3.cpp        -o rinside_sample3
make: Wall: Command not found
make: [rinside_sample3] Error 127 (ignored)
Wall  -s  rinside_sample4.cpp        -o rinside_sample4
make: Wall: Command not found
make: [rinside_sample4] Error 127 (ignored)
Wall  -s  rinside_sample5.cpp        -o rinside_sample5
make: Wall: Command not found
make: [rinside_sample5] Error 127 (ignored)
Wall  -s  rinside_sample6.cpp        -o rinside_sample6
make: Wall: Command not found
make: [rinside_sample6] Error 127 (ignored)
Wall  -s  rinside_sample7.cpp        -o rinside_sample7
make: Wall: Command not found
make: [rinside_sample7] Error 127 (ignored)
Wall  -s  rinside_sample8.cpp        -o rinside_sample8
make: Wall: Command not found
make: [rinside_sample8] Error 127 (ignored)
Wall  -s  rinside_sample9.cpp        -o rinside_sample9
make: Wall: Command not found
make: [rinside_sample9] Error 127 (ignored)
Wall  -s  rinside_test0.cpp        -o rinside_test0
make: Wall: Command not found
make: [rinside_test0] Error 127 (ignored)
Wall  -s  rinside_test1.cpp        -o rinside_test1
make: Wall: Command not found
make: [rinside_test1] Error 127 (ignored)

我尝试过 R_HOME 的不同路径,但我质疑我找到合适路径的能力。我是makefile的新手,所以错误输出没什么帮助。

希望有人有一些宝贵的见解可以分享!

提前致谢,

基督教

3 个答案:

答案 0 :(得分:6)

你似乎有两个不同的问题:

  1. 您的$PATH可能已关闭,或正如Josh暗示的那样,您的$R_HOME作业有误。如果make确实是Rtools中的二进制文件,并且您分配的路径是正确的,则构建成功。这是在Windows上构建R包的一般规则:非常努力地遵循手册 ,它将起作用。

  2. 在Windows上关闭了RInside,抱歉。它将构建,您将获得段错误。 Romain和我在文档中清楚地说明了这一点。

  3. 由于Romain和我几乎完全在OS X和Linux上工作,我们希望得到调试帮助。它应该是可行的,但它可能需要一些严肃的意愿来了解R内部,因为内存子系统中的某些内容会变得瘫痪。这显然不适用于名称中带有X的操作系统。

    2011年12月8日更新:截至今日,在CRAN上的RInside 0.2.5还原了Windows功能 - 使用其他评论中的修复James说明。

答案 1 :(得分:6)

我在工作中有类似的设置,所以我给了它一个镜头。在指定R_LIBS_SITE之后,我能够构建示例。请注意,它必须是 Windows 路径,而不是Cygwin路径!

export R_LIBS_SITE=c:/R/site-library

答案 2 :(得分:4)

今天我花了一点时间查看了使用Windows版本的RInside的bug。我相信我发现了如下的错误:

在RInside :: initialize(......)中填充了structRStart结构,但是现在需要在windows的情况下填充额外的字段,如R \ src \ gnuwin32 \ embedded.c中的Rf_initEmbeddedR()所示。

Rp->rhome = RHome;
Rp->home = getRUser();
Rp->CharacterMode = LinkDLL;
Rp->ReadConsole = myReadConsole;
Rp->WriteConsole = myWriteConsole;
Rp->CallBack = myCallBack;
Rp->ShowMessage = askok;
Rp->YesNoCancel = askyesnocancel;
Rp->Busy = myBusy;

为了提供有效的回调,必须在RInside.cpp中进行等效分配。