I am trying to call R functions from C ++ on Windows. I use MinGW to compile the program, but it throws an error when compiling. Code (taken from Dirk) and compilation error:
#include <iostream> using namespace std;
Compile:
g++ -I "C:\ProgramFiles\R\R-2.14.0\library\RInside\include" -I "C:\Progra mFiles\R\R-2.14.0\library\Rcpp\include" -I "C:\ProgramFiles\R\R-2.14.0\include" RFunctions.cpp -o sh1.exe
Error:
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x19a): und efined reference to `RInside::RInside(int, char const* const*, bool)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x1ee): und efined reference to `RInside::operator[](std::string const&)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x26d): und efined reference to `RInside::parseEval(std::string const&)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x35b): und efined reference to `RInside::~RInside()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x3e1): und efined reference to `RInside::~RInside()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp7RO bjectC2Ev[Rcpp::RObject::RObject()]+0x8): undefined reference to `vtable for Rcp p::RObject' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp7RO bjectC2Ev[Rcpp::RObject::RObject()]+0xd): undefined reference to `_imp__R_NilVal ue' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN7RInside 5ProxyD1Ev[RInside::Proxy::~Proxy()]+0xd): undefined reference to `Rcpp::RObject ::~RObject()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EED2Ev[Rcpp::Vector<14>::~Vector()]+0x16): undefined reference to `Rcpp ::RObject::~RObject()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EED1Ev[Rcpp::Vector<14>::~Vector()]+0x16): undefined reference to `Rcpp ::RObject::~RObject()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC1EP7SEXPREC[Rcpp::Vector<14>::Vector(SEXPREC*)]+0x57): undefined ref erence to `Rcpp::RObject::setSEXP(SEXPREC*)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC1EP7SEXPREC[Rcpp::Vector<14>::Vector(SEXPREC*)]+0x66): undefined ref erence to `Rcpp::RObject::~RObject()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ma trixILi14EEC1ERKiS3_[Rcpp::Matrix<14>::Matrix(int const&, int const&)]+0x2c): un defined reference to `Rcpp::Dimension::Dimension(unsigned int const&, unsigned i nt const&)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZNK4Rcpp6V ectorILi14EE4sizeEv[Rcpp::Vector<14>::size() const]+0x10): undefined reference t o `Rf_length' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6r_ castILi14EEEP7SEXPRECS2_[SEXPREC* Rcpp::r_cast<14>(SEXPREC*)]+0xd): undefined re ference to `TYPEOF' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6r_ castILi14EEEP7SEXPRECS2_[SEXPREC* Rcpp::r_cast<14>(SEXPREC*)]+0x1d): undefined r eference to `SEXPREC* Rcpp::internal::r_true_cast<14>(SEXPREC*)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)] +0x46): undefined reference to `Rcpp::Dimension::prod() const' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)] +0x56): undefined reference to `Rf_allocVector' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)] +0x67): undefined reference to `Rcpp::RObject::setSEXP(SEXPREC*)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)] +0x7d): undefined reference to `Rcpp::Dimension::size() const' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)] +0xc9): undefined reference to `Rcpp::RObject::attr(std::string const&) const' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)] +0x13b): undefined reference to `Rcpp::RObject::~RObject()' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZNK4Rcpp11 Environment6assignINS_6MatrixILi14EEEEEbRKSsRKT_[bool Rcpp::Environment::assign< Rcpp::Matrix<14> >(std::basic_string<char, std::char_traits<char>, std::allocato r<char> > const&, Rcpp::Matrix<14> const&) const]+0x23): undefined reference to `Rcpp::Environment::assign(std::string const&, SEXPREC*) const' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp7RO bject14AttributeProxyaSINS_9DimensionEEERS1_RKT_[Rcpp::RObject::AttributeProxy& Rcpp::RObject::AttributeProxy::operator=<Rcpp::Dimension>(Rcpp::Dimension const& )]+0x1c): undefined reference to `Rcpp::RObject::AttributeProxy::set(SEXPREC*) c onst' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp8in ternal13r_init_vectorILi14EEEvP7SEXPREC[void Rcpp::internal::r_init_vector<14>(S EXPREC*)]+0xd): undefined reference to `double* Rcpp::internal::r_vector_start<1 4, double>(SEXPREC*)' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp8in ternal13r_init_vectorILi14EEEvP7SEXPREC[void Rcpp::internal::r_init_vector<14>(S EXPREC*)]+0x23): undefined reference to `Rf_length' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp8in ternal21wrap_dispatch_unknownINS_9DimensionEEEP7SEXPRECRKT_NS_6traits17integral_ constantIbLb1EEE[SEXPREC* Rcpp::internal::wrap_dispatch_unknown<Rcpp::Dimension> (Rcpp::Dimension const&, Rcpp::traits::integral_constant<bool, true>)]+0xd): und efined reference to `Rcpp::Dimension::operator SEXPREC*() const' C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6tr aits14r_vector_cacheILi14EE6updateERKNS_6VectorILi14EEE[Rcpp::traits::r_vector_c ache<14>::update(Rcpp::Vector<14> const&)]+0x15): undefined reference to `double * Rcpp::internal::r_vector_start<14, double>(SEXPREC*)' collect2: ld returned 1 exit status
Any ideas what I am missing?
source share