[Rcpp-devel] basic usage help

Vinh Nguyen vinhdizzo at gmail.com
Thu May 27 01:08:11 CEST 2010


On Wed, May 26, 2010 at 11:29 AM, Vinh Nguyen <vinhdizzo at gmail.com> wrote:
>>> 6.  How do I compile the .cpp file on the
>>> command line?  I got the following based on Dirk's HPC talk but
>>> getting errors on my mac os x:
>>
>> The easiest way by far is to make a package and follow the guidelines of our
>> last release notes. See the section "Using Rcpp in other packages" here
>> http://romainfrancois.blog.free.fr/index.php?post/2010/05/17/Rcpp-0.8.0
>>
>>
>> The next easy way is to build on the smartness of the inline package. With
>> verbose = TRUE, it will show you how to run the show:
>>
>> fx <- cppfunction( , "return R_NilValue ;", verbose = TRUE )
>>
>>

Can you guys take a look at this and help?  First, I have Rcpp and
RcppArmadillo installed.  Don't know if I have to install Armadillo
itself.

I compile using:

~> PKG_CXXFLAGS="-I/gnet/home/home8/user24/nguyenv9/Rlib/Rcp
p/include -I/gne/home/nguyenv9/Rlib/RcppArmadillo/include" PKG_LIBS="-L/gnet/hom
e/home8/user24/nguyenv9/Rlib/Rcpp/lib -lRcpp -Wl,-rpath,/gnet/home/home8/user24/
nguyenv9/Rlib/Rcpp/lib -L/gne/home/nguyenv9/Rlib/RcppArmadillo/lib -Wl,-rpath,/g
ne/home/nguyenv9/Rlib/RcppArmadillo/lib" R CMD SHLIB PH_CIC_Rcpp.cpp
g++ -I/gne/home/nguyenv9/R-2.11.0/include  -I/usr/local/include   -I/gnet/home/h
ome8/user24/nguyenv9/Rlib/Rcpp/include -I/gne/home/nguyenv9/Rlib/RcppArmadillo/i
nclude -fpic  -g -O2 -c PH_CIC_Rcpp.cpp -o PH_CIC_Rcpp.o
g++ -shared -L/usr/local/lib64 -o PH_CIC_Rcpp.so PH_CIC_Rcpp.o -L/gnet/home/home
8/user24/nguyenv9/Rlib/Rcpp/lib -lRcpp -Wl,-rpath,/gnet/home/home8/user24/nguyen
v9/Rlib/Rcpp/lib -L/gne/home/nguyenv9/Rlib/RcppArmadillo/lib -Wl,-rpath,/gne/hom
e/nguyenv9/Rlib/RcppArmadillo/lib

everything is OK

In R:
> dyn.load("PH_CIC_Rcpp.so")
Error in dyn.load("PH_CIC_Rcpp.so") :
  unable to load shared library '/gnet/home/home8/user24/nguyenv9/PH_CIC_Rcpp.so
':
  /gnet/home/home8/user24/nguyenv9/PH_CIC_Rcpp.so: undefined symbol: dgetri_

NOTE: This error didn't begin to occur until I started doing matrix
inversion, additon, etc, usign the armadillo classes.

Also, I didn't include BLAS or LAPACK linking -- still don't know how
to get the compilation flags easily.   I read the skeleton stuff but I
don't understand (sorry).

Thanks.
Vinh


More information about the Rcpp-devel mailing list