[Rcpp-devel] Error with NumericMatrix using SourceCpp

Jaime Ashander jashander at ucdavis.edu
Thu Jan 2 23:36:55 CET 2014


I can't reproduce your error, but had some similar issues before updating
gcc and reinstalling Rcpp.

Providing output of
> sessionInfo()
from R, and details on compiler versions might help others point you to a
more specific solution.

- jaime

For reference, I have gcc i686-apple-darwin10-llvm-gcc-4.2 via mac ports
and my sessionInfo() gives:

R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

# ...
attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods
base

other attached packages:
 [1] RcppArmadillo_0.3.930.1 Rcpp_0.10.6



On Thu, Jan 2, 2014 at 2:20 PM, French, Joshua
<JOSHUA.FRENCH at ucdenver.edu>wrote:

> Hello everyone,
>
> I’m getting a weird error anytime I try to use a NumericMatrix in a
> function compiled using the sourceCpp function.  In case it matters, I’m
> running Mac OS X 10.9.1.
>
> I compiled a simple NumericVector function with no problem:
>
> library(Rcpp)
>
> src <- '
> #include <Rcpp.h>
> using namespace Rcpp;
> // [[Rcpp::export]]
> NumericVector fun1()
> {
> NumericVector a(3, 10.0);
> return(a);
> }
> '
> sourceCpp(code = src)
> fun1()
>
> When I try a similar function with a NumericMatrix, I get an error.  I
> tried to compile:
>
> src2 <- '
> #include <Rcpp.h>
> using namespace Rcpp;
> // [[Rcpp::export]]
> NumericMatrix fun2()
> {
> NumericMatrix a(3, 2);
> return a;
> }
> '
> sourceCpp(code = src2)
>
> And get the following error:
>
> Error in
> dyn.load("/var/folders/x7/cm9jq3nn6mxdn31r9sw3sbv80000gn/T//RtmpaRBweq/sourcecpp_15e0218ec23e/sourceCpp_38196.so")
> :
>   unable to load shared object
> '/var/folders/x7/cm9jq3nn6mxdn31r9sw3sbv80000gn/T//RtmpaRBweq/sourcecpp_15e0218ec23e/sourceCpp_38196.so':
>
> dlopen(/var/folders/x7/cm9jq3nn6mxdn31r9sw3sbv80000gn/T//RtmpaRBweq/sourcecpp_15e0218ec23e/sourceCpp_38196.so,
> 6): Symbol not found:
> __ZNK4Rcpp7RObject4attrERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
>   Referenced from:
> /var/folders/x7/cm9jq3nn6mxdn31r9sw3sbv80000gn/T//RtmpaRBweq/sourcecpp_15e0218ec23e/sourceCpp_38196.so
>   Expected in: flat namespace
>  in
> /var/folders/x7/cm9jq3nn6mxdn31r9sw3sbv80000gn/T//RtmpaRBweq/sourcecpp_15e0218ec23e/sourceCpp_38196.so
>
> Thinking perhaps I messed up, I tried to compile a stripped down Gibbs
> sampler example from Dirk to no avail (
> http://gallery.rcpp.org/articles/gibbs-sampler/).
>
> src3 <- '
> // load Rcpp
> #include <Rcpp.h>
>
> using namespace Rcpp; // shorthand
>
> // [[Rcpp::export]]
> NumericMatrix RcppGibbs(int n, int thn) {
>
>     int i,j;
>     NumericMatrix mat(n, 2);
>     return mat;             // Return to R
> }
> '
> sourceCpp(code = src3)
>
> What is going on?  If I am missing something very simple, please forgive
> me.  I’ve been beating my head against the wall for over an hour now
> looking at examples, trying to create the simplest tests possible, to no
> avail.
>
> Thanks,
>
> Joshua
>
> --
> Joshua French, Ph.D.
> Assistant Professor
> Department of Mathematical and Statistical Sciences
> University of Colorado Denver
> Joshua.French at ucdenver.edu
> http://math.ucdenver.edu/~jfrench/
> Ph:  303-315-1709  Fax:  303-315-1701
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140102/1ca1cb16/attachment.html>


More information about the Rcpp-devel mailing list