Using a different version of gcc from the version of Rtools with Rcpp on Windows

Before embarking on updating gcc, did anyone really try to do this, and can they confirm that building R from the source is required to update the version of gcc used to compile C ++ code with Rcpp (i.e. not necessary for creating packages and of course not for CRAN-valid packages)?

See Dirk's answer to this question and the following comment from the original poster How to use gcc 4.8.1 with Rcpp on Windows .

+4
source share
1 answer

R . , Windows 7 x64, R 3.1.1 Rtools 3.1.0.1942. gcc :

  • R remove.packages("Rcpp") - Rcpp. R.
  • MinGW- MinGW-builds.
  • gcc 4.8.1/Arch x64/Threads posix/Exception sjlj/ rev 5 []:\Rtools\mingw-builds \...
  • system PATH, ( PATH): [Drive]:\R\R-3.1.1\bin\x64;[Drive]:\Rtools\bin;[Drive]:\Rtools\mingw-build\x64-4.8.1-posix-sjlj-rev5\mingw64\bin\; , Rtools: [Drive]:\Rtools\gcc-4.6.3\bin

  • , PATH.

  • R install.packages("Rcpp") , 1.

R 3.1.1 (2014-07-10) Rcpp 0.11.2. rgui.exe, IDE, RStudio, - .

, system('gcc -v') R, :

COLLECT_GCC=F:\Rtools\MINGW-~1\X64-48~1.1-P\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=f:/rtools/mingw-~1/x64-48~1.1-p/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
[Edited Config info]
Thread model: posix
gcc version 4.8.1 (rev5, Built by MinGW-W64 project) 

, gcc 4.6.3 to 4.8.0, , C++11, gcc 4.8.*, R, Rcpp::sourceCpp , .cpp , ( gcc 4.6.3):

#include <Rcpp.h>

// [[Rcpp::plugins("cpp11")]]


template<typename T>
struct Wrap 
{
    int test2(int depth)
    {
        m_test++;
        std::vector<int> v = { 0, 1, 2, 3 };
        return depth == 0? 1 : std::accumulate(
             v.begin(), v.end(), int(0), [=](int sub, int const&) {
             return sub + test2(depth - 1);
             });   
    }

    int m_test = 0;
};


  struct X
{
  template <class T> static void bar() {}

  template <class T> void foo(T p) 
  {
    [&] { bar<T>(); };
  }
};

// [[Rcpp::export]]
double inheriting(int in_){

struct A { 
  A(int u){
    hello = u*u/2.0;
  }; 
double hello;
};

struct B: A { using A::A; };

  B b(in_);
  return(b.hello);
}

// [[Rcpp::export]]
void test_lambda(int in_)
{
  X x;
  x.foo(in_);
}

// [[Rcpp::export]]
int test_bug_4_7_2(int in_){

Wrap<int> w;
return w.test2(in_);
}
+6

All Articles