r - After including RcppArmadillo.h, errors occur when compiling code -
i use of functionalities included in rcpparmadillo. read in post on so, if rcpparmadillo.h included, rcpp.h should not included. did that, when trying compile .cpp file, got error messages. edit. per dirk's suggestion, included rcpparmadillo.h, reduced number of error messages: minimally reproducible code below:
#include <rcpparmadillo.h> // [[rcpp::depends(rcpparmadillo)]] using namespace rcpp; using namespace arma; template <class randomaccessiterator, class strictweakordering> void sort(randomaccessiterator first, randomaccessiterator last, strictweakordering comp); struct val_order{ int order; double value; }; bool compare(const val_order & a, const val_order & b){return (a.value<b.value);} // [[rcpp::export]] integervector order(numericvector x){ int n=x.size(); std::vector<int> output(n); std::vector<val_order> index(n); for(int i=0;i<x.size();i++){ index[i].value=x(i); index[i].order=i; } std::sort(index.begin(), index.end(), compare); for(int i=0;i<x.size();i++){ output[i]=index[i].order; } return wrap(output); } the error message below:
error in sourcecpp("functions.cpp") : error 1 occurred building shared library. ld: warning: directory not found option '-l/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64' ld: warning: directory not found option '-l/usr/local/lib/x86_64' ld: warning: directory not found option '-l/usr/local/lib/gcc/i686-apple-darwin8/4.2.3' ld: library not found -lgfortran collect2: ld returned 1 exit status make: *** [sourcecpp_44748.so] error 1 just reiterate, code has no problem compiling when use rcpp.h.
a few things:
your post not helpful. not need dozens of lines of error messages, need reproducible code. did not included.
you include several c++ headers and several r headers. don't.
include 1 header only: rcpparmadillo.h , if fails, post reproducible example.
edit: update. code compiles, error linker error. need install fortran compiler under os x.
Comments
Post a Comment