Skip to content
Prev 567 / 10988 Next

[Rcpp-devel] RcppArmadillo error

Le 31/03/10 15:25, Douglas Bates a ?crit :
I've attached an R file that contains the code that is on Dirk's 
RcppArmadillo page. The file compiles, links and load the code and run 
the function. (similar to what inline does but inline does not work here 
because it includes Rcpp.h too early, that's another story)

The key thing is that this is not linking against armadillo library or 
blas or lapack. I suppose the blas functions are retrieved from R's blas 
and lapack.

$ Rscript armaex.R
Le chargement a n?cessit? le package : inline
Le chargement a n?cessit? le package : methods
Le chargement a n?cessit? le package : Rcpp
g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include 
-I/Library/Frameworks/R.framework/Resources/include/x86_64 
-I/usr/local/include 
-I/Library/Frameworks/R.framework/Resources/library/Rcpp/lib/x86_64 
-I/Library/Frameworks/R.framework/Resources/library/RcppArmadillo/include -I/usr/include 
  -fPIC  -g -O3 -Wall -pipe -Wno-variadic-macros -c armaex.cpp -o armaex.o
g++-4.2 -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names 
-undefined dynamic_lookup -single_module -multiply_defined suppress 
-L/usr/local/lib -o armaex.so armaex.o 
/Library/Frameworks/R.framework/Resources/library/Rcpp/lib/x86_64/libRcpp.a 
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework 
-Wl,CoreFoundation
$coefficients
           [,1]
[1,] -2.353325
[2,]  2.199970

$stderr
            [,1]
[1,] 0.23066284
[2,] 0.08983455


(on OSX I need to use otool instead of ldd for some reason: )

$ otool -L armaex.so
armaex.so:
	armaex.so (compatibility version 0.0.0, current version 0.0.0)
	/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libR.dylib 
(compatibility version 2.11.0, current version 2.11.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.13.0)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current 
version 7.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 125.0.0)

and :

$ otool -L 
/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libR.dylib
/lib/libR.dylib
/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libR.dylib:
	/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libR.dylib 
(compatibility version 2.11.0, current version 2.11.0)
	/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libRblas.dylib (compatibility version 0.0.0, current version 0.0.0)
	/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libgfortran.2.dylib (compatibility version 3.0.0, current version 3.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 476.19.0)
	/Library/Frameworks/R.framework/Versions/2.11/Resources/lib/libreadline.5.2.dylib (compatibility version 5.0.0, current version 5.2.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
	/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current 
version 36.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 111.1.4)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 
7.0.0)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 
1.0.0)

so I suppose the reason why this works here is that blas and lapack from 
R are used.

Maybe we should remove the -L/usr/lib -larmadillo business in 
RcppArmadillo so that there is no confusion. We used to compile the 
package just fine without them, I think Dirk added the flags for some 
windows related reason.