I installed R along with RStudio and RTools and currently I'm trying to get Rcpp running. I tried this code as an testfile:
#include <RcppArmadillo.h>
#include <cmath.h>
//[[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
double Mutual_Information(
arma::mat joint_dist
){
joint_dist = joint_dist/sum(sum(joint_dist));
double mutual_information = 0;
int num_rows = joint_dist.n_rows;
int num_cols = joint_dist.n_cols;
arma::mat colsums = sum(joint_dist,0);
arma::mat rowsums = sum(joint_dist,1);
for(int i = 0; i < num_rows; ++i){
for(int j = 0; j < num_cols; ++j){
double temp = log((joint_dist(i,j)/(colsums[j]*rowsums[i])));
if(!std::isfinite(temp)){
temp = 0;
}
mutual_information += joint_dist(i,j) * temp;
}
}
return mutual_information;
}
but I get this error message:
c:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-34~1.2/include" -DNDEBUG -I../inst/include -fopenmp -I"C:/Users/root/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/root/Documents/R/win-library/3.4/RcppArmadillo/include" -I"C:/Users/root/OneDrive/Uni/SEMEST~1/PROJEK~1/test/src" -I"C:/Users/root/OneDrive/Uni/Semester 3/Projektarbeit/test/inst/include"
-I"d:/Compiler/gcc-4.9.3/local330/include" -O2 -Wall -mtune=core2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o rcpp_hello_world.cpp:2:19: fatal error: cmath.h: No such file or directory #include ^ compilation terminated. make: *** [rcpp_hello_world.o]
Error 1 Warnmeldung: Ausführung von Kommando 'make -f "C:/PROGRA~1/R/R-34~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-34~1.2/share/make/winshlib.mk" CXX='$(CXX11) $(CXX11STD)' CXXFLAGS='$(CXX11FLAGS)' CXXPICFLAGS='$(CXX11PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX11LDFLAGS)' SHLIB_LD='$(SHLIB_CXX11LD)' SHLIB="sourceCpp_3.dll" WIN=64 TCLBIN=64 OBJECTS="rcpp_hello_world.o"' ergab Status 2 Error in Rcpp::sourceCpp("src/rcpp_hello_world.cpp") : Error 1 occurred building shared library. In addition: Warning message: In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/root/OneDrive/Uni/Semester 3/Projektarbeit/test/src/../inst/include": Das System kann den angegebenen Pfad nicht finden
library("Rcpp") and library("RcppArmadillo") are loaded successfully ...
So as I understand this error it could not find the include file. The path the compiler is looking for does not exist. It should handle the include path itself I assume .. Including this header file in QT or Visual Studio works without any errors ..
Do I need to adjust some PATH settings? I'm running this on Windows 10 x64 I can't find any solution using google so I hope you can help me on this. Thanks a lot