[Rcpp-devel] Error with NumericMatrix using SourceCpp

French, Joshua JOSHUA.FRENCH at UCDENVER.EDU
Fri Jan 3 03:25:20 CET 2014


Hello Hao,

Thank you for the advice.  That did the trick!  Here is a relevant thread about something similar on StackOverflow (http://stackoverflow.com/questions/20572535/error-in-dyn-load-in-rcpp-package-in-mac)).

Joshua
--
Joshua French, Ph.D.
Assistant Professor
Department of Mathematical and Statistical Sciences
University of Colorado Denver
Joshua.French at ucdenver.edu<mailto:Joshua.French at ucdenver.edu>
http://math.ucdenver.edu/~jfrench/
Ph:  303-315-1709  Fax:  303-315-1701

From: Hao Ye <hye at ucsd.edu<mailto:hye at ucsd.edu>>
Date: Thursday, January 2, 2014 at 5:27 PM
To: Joshua French <joshua.french at ucdenver.edu<mailto:joshua.french at ucdenver.edu>>
Subject: Re: [Rcpp-devel] Error with NumericMatrix using SourceCpp

Hi Joshua,

I had the same problem a month or two ago. Try installing Rcpp from source. (that did the trick for me)

Best,
--
Hao Ye
hye at ucsd.edu<mailto:hye at ucsd.edu>

On Jan 2, 2014, at 5:20 PM, French, Joshua <JOSHUA.FRENCH at UCDENVER.EDU<mailto: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<mailto: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<mailto: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/d4f20ce0/attachment.html>


More information about the Rcpp-devel mailing list