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);
}