Search code examples
c++rrcppcran

C++ compiling error while compiling R package on Winbuild


My package (slfm) uses Rcpp to connect C++ code to R. Its check runs OK on linux, but I get this error when trying to compile it using WinBuild:

* installing *source* package 'slfm' ...
** libs

*** arch - i386
g++  -I"D:/RCompile/recent/R-3.1.2/include"            -I"d:/RCompile/CRANpkg/lib/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/lib/3.1/RcppArmadillo/include" -I"d:/Rcompile/CRANpkg/extralibs215/local215/include"     -O3 -Wall  -mtune=core2            -c RcppExports.cpp -o RcppExports.o
g++  -I"D:/RCompile/recent/R-3.1.2/include"            -I"d:/RCompile/CRANpkg/lib/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/lib/3.1/RcppArmadillo/include" -I"d:/Rcompile/CRANpkg/extralibs215/local215/include"     -O3 -Wall  -mtune=core2            -c gibbs.cpp -o gibbs.o
g++ -shared -s -static-libgcc -o slfm.dll tmp.def RcppExports.o gibbs.o -Ld:/Rcompile/CRANpkg/extralibs215/local215/lib/i386 -Ld:/Rcompile/CRANpkg/extralibs215/local215/lib -LD:/RCompile/recent/R-3.1.2/bin/i386 -lR
gibbs.o:gibbs.cpp:(.text+0x125e): undefined reference to `ddot_'
gibbs.o:gibbs.cpp:(.text+0x1981): undefined reference to `dgemv_'
gibbs.o:gibbs.cpp:(.text+0x22f9): undefined reference to `dgemv_'
gibbs.o:gibbs.cpp:(.text$_ZN4arma10glue_times5applyIdLb0ELb0ELb0ENS_3MatIdEENS_3ColIdEEEEvRNS2_IT_EERKT3_RKT4_S6_[void arma::glue_times::apply<double, false, false, false, arma::Mat<double>, arma::Col<double> >(arma::Mat<double>&, arma::Mat<double> const&, arma::Col<double> const&, double)]+0x1bf): undefined reference to `dgemv_'
gibbs.o:gibbs.cpp:(.text$_ZN4arma10glue_times5applyIdLb1ELb0ELb0ENS_3ColIdEENS_3MatIdEEEEvRNS4_IT_EERKT3_RKT4_S6_[void arma::glue_times::apply<double, true, false, false, arma::Col<double>, arma::Mat<double> >(arma::Mat<double>&, arma::Col<double> const&, arma::Mat<double> const&, double)]+0x251): undefined reference to `dgemv_'
gibbs.o:gibbs.cpp:(.text$_ZN4arma4gemvILb1ELb0ELb0EE15apply_blas_typeIdNS_3MatIdEEEEvPT_RKT0_PKS5_S5_S5_[void arma::gemv<true, false, false>::apply_blas_type<double, arma::Mat<double> >(double*, arma::Mat<double> const&, double const*, double, double)]+0x87): undefined reference to `dgemv_'
collect2: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'slfm'
* removing 'd:/RCompile/CRANguest/R-release/lib/slfm'

Has anyone experienced it before? Is it related to configuring Rcpp? Strange thing is: I haven't changed anything on Rcpp configuration, just some simple lines on C++ code and it was running OK before. Version 0.1 in CRAN is stable.


Solution

  • You are not linking with the LAPACK and BLAS libraries which are used by the code.

    Easiest fix: look at the Makefile.win created by the package skeleton generator.