1

Further investigation suggests (the problem with the call to #include at least) is due to some issues with Windows 8.1. I will confirm this when I get a chance on another OS. My issue is highlighted as basically the same problem the person in this post was having: 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

I am experimenting with embedding some R-Code in a c++ application for a project I am working on I am trying to use RInside to do this as, from discussions I've read online at least, it seems to be the best way to do this.

Setup:

System: HP Pavilion

OS: Windows 8.1

R: 3.1.1

Rtools: 3.1.0.1942

Rcpp: 0.11.0

RInside: 0.2.11

RInside: 0.2.11

Here is the relevant piece of my PATH variable in case it's an error with that.

EDIT: Have now included full 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\x64

C:\R\batchfiles_0.7-1;

C:\Windows\system32;

C:\Windows;

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\;

EDIT: The original error has been put to the bottom of the post. New error: Simplified the example. I now have no error with compilation but an error at execution - "The application was unable to start correctly (0xc000007b). Click OK to close the application." I think this is a .dll problem - any recommendations (i.e., should I be looking in the gcc-4.6.3 folder)?

This error only occurs once the '#include ' line is added.

The code used is:

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

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

The Makefile.win is (Note that I had to set the R_HOME variable manually - should I do the same for the library somehow?):

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

I have installed and run some of the sample codes for Rcpp in the R terminal with no issues. I have tried several times to follow the examples given in the instructions for installing RInside but I haven't been able to get them to work. When I try "make -f Makefile.win" in the standard folder of the example I get the following error:

In function 'int main(int, char**)':

error: 'Shield' was not declared in this scope

note: suggested alternative:

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

error: expected primary-expression before '>' token

error: expected '>' before ';' token

error: '_ _load_module_call_ _' was not declared in this scope

error: expected ';' before '>' token

make: * [rinside_module_sample0] Error 1

Original Code:

// -*- 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);
}
AodhanOL
  • 630
  • 7
  • 26
  • You may have another g++ in your path. RInside works with current or recent Rcpp headers, including the definition of Shield. I very strongly suspect something at your setup. – Dirk Eddelbuettel Sep 03 '14 at 15:44
  • Thank you, will look more closely at the path. By the way, having looked over a lot of RInside posts over the course of the day, you have a remarkable posting rate/response time. Thanks for the help you've been in the other problems I've experienced as well! – AodhanOL Sep 03 '14 at 15:46
  • I can't find anything in my path that leads me to think it's an issue of a duplicate g++. I've included it in my post, if you have time to look at it could you highlight anything you think is a problem area? – AodhanOL Sep 03 '14 at 16:30
  • Well, it works for others. Maybe you have an old version of Rcpp somewhere. It is hard for me to say what your problem might be. – Dirk Eddelbuettel Sep 03 '14 at 16:32
  • Fair enough, thanks, in any case. Somewhat annoying for me, I'll see what I can do. – AodhanOL Sep 03 '14 at 16:34
  • If you have access to another (Linux or OS X) machine ... – Dirk Eddelbuettel Sep 03 '14 at 16:36
  • I'll try that when I'm at home. I'm not sure if it working will make me feel better or worse, but I'll try it on Ubuntu at home. – AodhanOL Sep 03 '14 at 16:51
  • I tried this setup in Ubuntu 12.04 on my home machine and got the same result, including the Shield error. I'll try it with an older version of R maybe and see if that solves the issue. Will let you know. – AodhanOL Sep 04 '14 at 00:37
  • Makes no sense to me _as I have been writing / Rcpp for years on Ubuntu systems_. Make sure you have no older version of Rcpp from the distro conflicting with the current CRAN release version. And I just posted the basic `rinside_sample0` compilation on rcpp-devel within the last few days. It surely works here, and for many others. – Dirk Eddelbuettel Sep 04 '14 at 00:40
  • It makes no sense to me either, unfortunately! Thank you for your help. If I resolve the issue I will post here. I will check for any file clashes. – AodhanOL Sep 04 '14 at 08:31
  • Having had some time to think about it I decided to simplify the example. I now have no error with compilation but an error at execution - The application was unable to start correctly (0xc000007b). Click OK to close the application. I think this is a .dll problem - any recommendations (i.e., should I be looking in the gcc-4.6.3 folder)? Editing question to reflect new example. – AodhanOL Sep 04 '14 at 09:19

0 Answers0