SwatchPuppy
SwatchPuppy

Reputation: 334

Rcpp map return

I am trying to return a map from c++ to r. My code in c++ is the following (as found in https://github.com/RcppCore/Rcpp/blob/master/inst/tinytest/cpp/wrap.cpp):

#include <Rcpp.h>

using namespace Rcpp;

// [[Rcpp::export]]
IntegerVector map_string_int(){
    std::map< std::string, int > m ;
     m["b"] = 100;
    m["a"] = 200;
    m["c"] = 300;
    return wrap(m);
}

My r code is the following:

require(Rcpp)
Rcpp::sourceCpp(test.cpp')
map_string_int()

Although the code compiles without any error, when i call the function, my r session terminates immediately. Any ideas?

[EDIT]

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 
[2] LC_CTYPE=Portuguese_Portugal.1252   
[3] LC_MONETARY=Portuguese_Portugal.1252
[4] LC_NUMERIC=C                        
[5] LC_TIME=Portuguese_Portugal.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] Rcpp_0.11.3

loaded via a namespace (and not attached):
[1] tools_3.1.1

Upvotes: 1

Views: 199

Answers (1)

SwatchPuppy
SwatchPuppy

Reputation: 334

Decided to try another compiler and it worked!

I have installed Rtools compiler (http://cran.r-project.org/bin/windows/Rtools/) after which just changed the system path to point to the bin folders within the Rtools installation folder.

Upvotes: 1

Related Questions