[Rcpp-devel] Compilation errors when building a package with RcppArmadillo code and using attributes

Howard Zail howard at zail.org
Sun Dec 2 14:35:28 CET 2012


I am trying to build a package with RcppArmadillo code and using the new
attributes-type methodology.  When I compile using sourceCpp() the
functions compile and work.  However when I use
"Rcpp.package.skeleton("NewPackage", example_code = FALSE, cpp_files =
c("test_arma3.cpp"))", and then "R CMD INSTALL...." I get compilation
errors.  Here is some sample Armadillo code (the fastLM example) which is
then followed by the compilation errors.  Any help would be much
appreciated.
Thanks,

Sample Code:

// [[Rcpp::depends(RcppArmadillo)]]


#include <Rcpp.h>
#include <RcppArmadillo.h>

using namespace Rcpp;


// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
// [[Rcpp::export]]
List fastLm(NumericVector yr, NumericMatrix Xr) {
      int n = Xr.nrow(), k = Xr.ncol();
  arma::mat X(Xr.begin(), n, k, false);
  arma::colvec y(yr.begin(), yr.size(), false);
  arma::colvec coef = arma::solve(X, y);
  arma::colvec resid = y - X*coef;
  double sig2 = arma::as_scalar(arma::trans(resid)*resid/(n-k));
  arma::colvec stderrest = arma::sqrt(
  sig2 * arma::diagvec( arma::inv(arma::trans(X)*X)) );
  return List::create(Named("coefficients") = coef,
  Named("stderr") = stderrest);
}


Which produces the following errors when building the package:



> Rcpp::compileAttributes()

* Updated src/RcppExports.cpp

==> Rcmd.exe INSTALL --no-multiarch NewPackage

* installing to library 'C:/Users/Howard/Documents/R/win-library/2.15'
* installing *source* package 'NewPackage' ...
** libs
g++ -m64 -I"C:/R/R-2-15-2/include" -DNDEBUG
-I"C:/Users/Howard/Documents/R/win-library/2.15/Rcpp/include"
-I"C:/Users/Howard/Documents/R/win-library/2.15/RcppArmadillo/include"
-I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall
-mtune=core2 -c RcppExports.cpp -o RcppExports.o
g++ -m64 -I"C:/R/R-2-15-2/include" -DNDEBUG
-I"C:/Users/Howard/Documents/R/win-library/2.15/Rcpp/include"
-I"C:/Users/Howard/Documents/R/win-library/2.15/RcppArmadillo/include"
-I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall
-mtune=core2 -c test_arma3.cpp -o test_arma3.o
g++ -m64 -shared -s -static-libgcc -o NewPackage.dll tmp.def
RcppExports.o test_arma3.o
C:/Users/Howard/Documents/R/win-library/2.15/Rcpp/lib/x64/libRcpp.a
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-2-15-2/bin/x64
-lR
test_arma3.o:test_arma3.cpp:(.text+0xae4): undefined reference to `dgemm_'
test_arma3.o:test_arma3.cpp:(.text+0x19db): undefined reference to `dgemm_'
test_arma3.o:test_arma3.cpp:(.text+0x1b0c): undefined reference to `dgemv_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma6auxlib8solve_odIdNS_3MatIdEEEEbRNS2_IT_EES6_RKNS_4BaseIS4_T0_EE[_ZN4arma6auxlib8solve_odIdNS_3MatIdEEEEbRNS2_IT_EES6_RKNS_4BaseIS4_T0_EE]+0x702):
undefined reference to `dgels_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma6auxlib8solve_udIdNS_3MatIdEEEEbRNS2_IT_EES6_RKNS_4BaseIS4_T0_EE[_ZN4arma6auxlib8solve_udIdNS_3MatIdEEEEbRNS2_IT_EES6_RKNS_4BaseIS4_T0_EE]+0x51c):
undefined reference to `dgels_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma6auxlib10det_lapackIdEET_RKNS_3MatIS2_EEb[_ZN4arma6auxlib10det_lapackIdEET_RKNS_3MatIS2_EEb]+0x14b):
undefined reference to `dgetrf_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma6auxlib5solveIdNS_3MatIdEEEEbRNS2_IT_EES6_RKNS_4BaseIS4_T0_EEb[_ZN4arma6auxlib5solveIdNS_3MatIdEEEEbRNS2_IT_EES6_RKNS_4BaseIS4_T0_EEb]+0x375):
undefined reference to `dgesv_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma4gemvILb1ELb0ELb0EE15apply_blas_typeIdEEvPT_RKNS_3MatIS3_EEPKS3_S3_S3_[_ZN4arma4gemvILb1ELb0ELb0EE15apply_blas_typeIdEEvPT_RKNS_3MatIS3_EEPKS3_S3_S3_]+0x17d):
undefined reference to `dgemv_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_2OpINS_3MatIdEENS_9op_htransEEES5_EEvRNS4_INT_9elem_typeEEERKNS_4GlueIS8_T0_NS_10glue_timesEEE[_ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_2OpINS_3MatIdEENS_9op_htransEEES5_EEvRNS4_INT_9elem_typeEEERKNS_4GlueIS8_T0_NS_10glue_timesEEE]+0x37a):
undefined reference to `dgemm_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE[_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE]+0x2c1):
undefined reference to `dgetrf_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE[_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE]+0x322):
undefined reference to `dgetri_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE[_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE]+0x398):
undefined reference to `dgetri_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE[_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE]+0x775):
undefined reference to `dgetrf_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE[_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE]+0x7d6):
undefined reference to `dgetri_'
test_arma3.o:test_arma3.cpp:(.text$_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE[_ZN4arma10op_diagvec5applyINS_2OpINS_4GlueINS2_INS_3MatIdEENS_9op_htransEEES5_NS_10glue_timesEEENS_6op_invEEEEEvRNS4_INT_9elem_typeEEERKNS2_ISC_S0_EE]+0x892):
undefined reference to `dgetri_'
collect2: ld returned 1 exit status
ERROR: compilation failed for package 'NewPackage'
* removing 'C:/Users/Howard/Documents/R/win-library/2.15/NewPackage'
* restoring previous 'C:/Users/Howard/Documents/R/win-library/2.15/NewPackage'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121202/315c103d/attachment.html>


More information about the Rcpp-devel mailing list