How to make Rcpp work?

I cannot get Rcpp to work on Windows 8.1. When I run the following minimal example, I get an error.

> library(Rcpp) > evalCpp("1 + 1") g++ -m64 -I"C:/R/R-31~1.0/include" -DNDEBUG -I"C:/R/R-3.1.0/library/Rcpp/include" - I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c file11dc2120723d.cpp -o file11dc2120723d.o g++: not found make: *** [file11dc2120723d.o] Error 127 Warning message: running command 'make -f "C:/R/R-31~1.0/etc/x64/Makeconf" -f "C:/R/R-31~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_97232.dll" WIN=64 TCLBIN=64 OBJECTS="file11dc2120723d.o"' had status 2 Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, : Error 1 occurred building shared library. 

The first two elements in my path: PATH = C: \ Rtools \ Bin; C: \ Rtools \ GCC-4.6.3 \ Bin;

R is installed in the C: \ R \ R-3.1.0 directory

Rtools is located in the directory C: \ R \ Rtools

Additional Information:

 > library(devtools) > find_rtools(T) Scanning path... ls : c:\Rtools\bin\ls.exe Scanning registry... Found c:/Rtools for 3.1 VERSION.txt Rtools version 3.1.0.1942 [1] TRUE > has_devel() "C:/R/R-31~1.0/bin/x64/R" --vanilla CMD SHLIB foo.c gcc -m64 -I"C:/R/R-31~1.0/include" -DNDEBUG -I"d:/RCompile/CRANpkg/extralibs64/local/include" O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o gcc: not found make: *** [foo.o] Error 127 Warning message: running command 'make -f "C:/R/R-31~1.0/etc/x64/Makeconf" -f "C:/R/R-31~1.0/share/make/winshlib.mk" SHLIB="foo.dll" WIN=64 TCLBIN=64 OBJECTS="foo.o"' had status 2 Error: Command failed (1) > system('g++ -v') Warning message: running command 'g++ -v' had status 127 
+6
source share
3 answers

Not sure if you solved the problem, but it looks like you don't have gcc or g ++. For windows, you can get these tools with MinGW.

  • Install MinGW, which you can download from here . Home page for information here.

  • After installing MinGW, you can open the "MinGW Installation Manager" and install bin and dev for "mingw32-gcc-g ++".

  • Then you must update your PATH environment variable to include "C: \ MinGW \ bin" and "C: \ MinGW \ msys \ 1.0 \ bin".

  • Restart the R session, do not hurt to reinstall "Rcpp" as well and try require(Rcpp); evalCpp("1 + 1") again require(Rcpp); evalCpp("1 + 1") require(Rcpp); evalCpp("1 + 1") .

0
source

I had this problem when trying to directly call C code. Switching from a functional system () to system2 () solved it immediately.

0
source

I got this fix by installing RTools and adding RBuildTools to the path:

 Sys.setenv("PATH" = paste(Sys.getenv("PATH"), "C:\\RBuildTools\\3.4\\bin", "C:\\RBuildTools\\3.4\\mingw_32", "C:\\RBuildTools\\3.4\\mingw_64", sep = ";")) 

I do not understand these things, but @cdeterman's solutions did not work to create my package until its evalCpp("1 + 1") example did.

0
source

All Articles