1

进一步调查表明(至少调用#include 的问题)是由于Windows 8.1 的一些问题。当我有机会在另一个操作系统上时,我会确认这一点。我的问题被强调为与这篇文章中的人基本相同的问题:http: //answers.microsoft.com/en-us/windows/forum/windows8_1-performance/32-bit-application-fails-to-start -81 升级后/b825723e-e2a2-4c8f-bd1f-10446a5d7059

我正在尝试将一些 R 代码嵌入到我正在从事的项目的 c++ 应用程序中这个。

设置:

系统:HP Pavilion

操作系统:Windows 8.1

R:3.1.1

工具:3.1.0.1942

RCPP:0.11.0

R内部:0.2.11

R内部:0.2.11

这是我的 PATH 变量的相关部分,以防万一出现错误。

编辑:现在已经包含了完整的路径。

C:\R\R工具\bin;

C:\R\Rtools\gcc-4.6.3\bin;

C:\R\R-3.1.1\bin;

C:\R\R-3.1.1\bin\x64

C:\R\batchfiles_0.7-1;

C:\Windows\system32;

C:\视窗;

C:\Windows\System32\Wbem;

C:\Windows\System32\WindowsPowerShell\v1.0\;

C:\Program Files\惠普\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**)'中:

错误:未在此范围内声明“屏蔽”

注意:建议的替代方案:

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

错误:“>”标记之前的预期主表达式

错误:预期在 ';' 之前有 '>' 令牌

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

错误:预期的';' 在“>”标记之前

制作:* [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);
}
4

0 回答 0