[Rcpp-devel] RcppArmadillo solve function, dyn.load error

Dirk Eddelbuettel edd at debian.org
Mon May 7 00:29:13 CEST 2012


Ayn,

On 6 May 2012 at 14:38, Ayn Leslie-Cook wrote:
| Hi all,
| 
| I'm a student at the University of Washington and my course project this spring
| involves rewriting the 'svmpath' R package into C++ using Rcpp and
| RccpArmadillo.  Everything runs beautifully until I try to include the
| function below:
| 
| vec solveKstar(mat Kstar){
|   vec onestar = ones<vec>(Kstar.n_cols);
|   onestar[0]=0;
|                                                                                                                                         
|   vec solution;
|                                                                                                                                                           
|   solution=solve(trimatu(Kstar),onestar);
|   return solution;
| }
| 
| If I run R CMD INSTALL on my package removing the call to 'solve' everything
| runs fine, but if I included the call to 'solve' then the R CMD INSTALL input
| is
| 
| 
| // all the typical output
| 
| * installing to library ‘/net/home/aynlc3/Rlib’
| * installing *source* package ‘aynSVMpath’ ...
| ** libs
| g++ -I/usr/share/R/include -DNDEBUG   -I"/net/home/aynlc3/Rlib/Rcpp/include"
| -I"/net/home/aynlc3/Rlib/RcppArmadillo/include"   -fpic  -O3 -pipe  -g  -c
| aynSVMpath.cpp -o aynSVMpath.o
| g++ -I/usr/share/R/include -DNDEBUG   -I"/net/home/aynlc3/Rlib/Rcpp/include"
| -I"/net/home/aynlc3/Rlib/RcppArmadillo/include"   -fpic  -O3 -pipe  -g  -c
| svmHelpers.cpp -o svmHelpers.o
| g++ -shared -o aynSVMpath.so aynSVMpath.o initializations.o svmHelpers.o
| usetFunctions.o -L/net/home/aynlc3/Rlib/Rcpp/lib -lRcpp -Wl,-rpath,/net/home/
| aynlc3/Rlib/Rcpp/lib -L/usr/lib/R/lib -lR
| installing to /net/home/aynlc3/Rlib/aynSVMpath/libs

Your src/Makevars is insufficient -- use something like

  PKG_LIBS= `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) 

so that you link against LAPACK and BLAS as well.

| ** R
| ** preparing package for lazy loading
| ** help
| *** installing help indices
| ** building package indices
| ** testing if installed package can be loaded
| 
|            // then
| 
| Error in dyn.load(file, DLLpath = DLLpath, ...) :
|   unable to load shared object '/net/home/aynlc3/Rlib/aynSVMpath/libs/
| aynSVMpath.so':
|   /net/home/aynlc3/Rlib/aynSVMpath/libs/aynSVMpath.so: undefined symbol:
| dtrtrs_
| 
| 
| If I change 3rd and 4th lines of the 'solveKstar' function to:
| 
|   vec solution;
|                                                                                                                                                           
| 
|   solution=solve(Kstar,onestar);    // removing the call to 'trimatu'
| 
| the R CMD INSTALL output has the same typical output above, but with the
| following change to the error
| 
| Error in dyn.load(file, DLLpath = DLLpath, ...) :
|   unable to load shared object '/net/home/aynlc3/Rlib/aynSVMpath/libs/
| aynSVMpath.so':
|   /net/home/aynlc3/Rlib/aynSVMpath/libs/aynSVMpath.so: undefined symbol:
| dgels_
| 
| 
| The symbols 'dtrtrs_' and 'dgels_' are not part of my code;  from digging
| online, I believe these are coming from the lapack library, but I'm not sure
| how to proceed with that knowledge.  Does anyone have any advice?

Yes, once you link with LAPACK and BLAS you should be fine.  Let us know if
that works.

Dirk

|  Also, if relevant, I'm running R 2.15.0, Rcpp_0.9.10 and
| RcppArmadillo_0.3.0.2 on mosix. 
| 
| Many thanks,
| 
| Ayn
| 
| 
| 
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL
See agenda, registration details and more at http://www.RinFinance.com


More information about the Rcpp-devel mailing list