RInside编译错误(可能是由于Rcpp中的屏蔽)

时间:2014-09-03 15:29:59

标签: c++ r makefile rcpp rinside

进一步调查显示(至少调用#include的问题)是由于Windows 8.1的一些问题。当我有机会在另一个操作系统上时,我会确认这一点。我的问题突出显示为与此帖子中的人员基本相同的问题:http://answers.microsoft.com/en-us/windows/forum/windows8_1-performance/32-bit-application-fails-to-start-after-81-upgrade/b825723e-e2a2-4c8f-bd1f-10446a5d7059

我正在尝试在我正在研究的项目的c ++应用程序中嵌入一些R-Code我正在尝试使用RInside这样做,因为我至少在线阅读的讨论,它似乎是最好的这样做的方式。

设置:

  

系统:HP Pavilion

     

操作系统:Windows 8.1

     

R:3.1.1

     

Rtools:3.1.0.1942

     

Rcpp:0.11.0

     

RInside:0.2.11

     

RInside:0.2.11

这是我的PATH变量的相关部分,如果它是错误的话。

编辑:现在已包含完整的PATH。

  

C:\ r \ Rtools \ BIN;

     

C:\ r \ Rtools \ GCC-4.6.3 \ BIN;

     

C:\ r \ R-3.1.1 \ BIN;

     

C:\ r \ R-3.1.1 \ BIN \ 64

     

C:\ r \ batchfiles_0.7-1;

     

C:\ Windows \ System32下;

     

C:\视窗;

     

C:\ Windows \ System32下\ WBEM;

     

C:\ Windows \ System32下\ WindowsPowerShell \ V1.0 \;

     

C:\ Program Files \ Hewlett-Packard \ SimplePass \;

     

C:\ Program Files(x86)\ ATI Technologies \ ATI.ACE \ Core-Static;

     

C:\ Perl64 \ BIN;

     

C:\ MiKTeX 2.9 \ miktex \ bin \;

编辑:原始错误已放在帖子的底部。新错误:简化示例。我现在没有编译错误但执行时出错 - “应用程序无法正确启动(0xc000007b)。单击确定关闭应用程序。”我认为这是一个.dll问题 - 任何建议(即,我应该在gcc-4.6.3文件夹中查找)?

只有在添加'#include'行后才会出现此错误。

使用的代码是:

#include <iostream>
#include <RInside.h>

int main()
{
  std::cout << "Hello World!";
}

Makefile.win是(注意我必须手动设置R_HOME变量 - 我应该以某种方式为库做同样的事情吗?):

## -*- mode: makefile; tab-width: 8; -*-
##
## Simple Makefile for Windows
##
## Note that the libRInside library encodes the value of R_HOME found
## at compilation. So if you use the CRAN package of RInside, its value
## may not correspond to where you have R installed.  One quick fix is 
## export the appropriate value of R_HOME, eg ony my work machine
##           set R_HOME=C:\opt\R-current
## The other is to re-install RInside from source on your machine.
## Either one should allow you to actually run the binaries created
## with this Makefile


## This version is fairly directly derived from the Unix versions
## You may have to set R_HOME manually if this does not work
## It requires Rtools in the path -- as does all R package building
R_HOME :=       C:/R/R-3.1.1/

## You may have to set this to one of the two values below to enforce a  particular
## architecture in case the autodetection in the next line does not work correctly
R_ARCH :=       --arch $(shell echo 'cat(.Platform$$r_arch)' | R --vanilla --slave)
##R_ARCH :=     --arch i386
##R_ARCH :=     --arch x64

## You may need to set R_LIBS_USER if Rcpp or RInside are installed where R does not see them by default
#R_LIBS_USER :=     "C:/myRstuff/library"

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

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


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


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


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


all :           $(programs)

clean:
            rm -vf $(programs)

checkR:
            echo "R is at $(R_HOME)"

我已经在R终端中安装并运行了一些Rcpp的示例代码而没有任何问题。我曾多次尝试按照安装RInside的说明中给出的示例进行操作,但我无法让它们工作。当我在示例的标准文件夹中尝试“make -f Makefile.win”时,我收到以下错误:

  

在函数'int main(int,char **)'中:

     

错误:未在此范围内声明'Shield'

     

注意:建议替代方案:

     

C:/R/R-3.1.1/library/Rcpp/include/Rcpp/protection/Shield.h:29:11:   注意:'Rcpp:Shield'

     

错误:在'&gt;'之前预期的primary-expression令牌

     

错误:预期'&gt;'在';'之前令牌

     

错误:未在此范围内声明'_ _load_module_call_ _'

     

错误:预期';'在'&gt;'之前令牌

     

make: * [rinside_module_sample0]错误1

原始代码:

// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4;  tab-width: 8; -*-
//
// Simple example showing how to do the standard 'hello, world' using embedded R
//
// Copyright (C) 2009 Dirk Eddelbuettel 
// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
//
// GPL'ed 

#include <RInside.h>                    // for the embedded R via RInside

int main(int argc, char *argv[]) {

    RInside R(argc, argv);              // create an embedded R instance 
    #if defined(RINSIDE_CALLBACKS)
    R.set_callbacks( new Callbacks() );
    R.repl() ;
    #endif
    exit(0);
}

0 个答案:

没有答案