[Rcpp-devel] Attribute does not compile with 'compileAttributes' but with 'sourceCpp'
Simon Zehnder
szehnder at uni-bonn.de
Fri Nov 1 18:04:23 CET 2013
J.J.,
I went now on the cluster Linux Scientific and used there compileAttributes (also with gcc-4.8.2). There were no problems.
On my Mac I figured out, where exactly in the compileAttributes function in attributes.cpp the error happens:
On line 2794 with generators.writeBegin()
And further in the for loop at 1926 in iteration 3, which I believe calls writeFunctions of the CppExportsIncludeGenerator. I then started at the constructor for this class at line 1578 and used an Rprintf(“”) to give me the includeDir_ path string. When I then tried to compile Rcpp from the shell I got a weird error during linking:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: changing install names or rpaths can't be redone for: libRcpp.dylib (for architecture x86_64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
I recompiled Rcpp, including in the MAKEFLAGS=“CXXFLAGS=-headerpad_max_install_names” (described here: http://www.manpages.info/macosx/ld.1.html) and it worked fine. Running afterwards compileAttributes in R did not throw any error. I got the includeDir_: mypackage/inst/include/. RcppExports.cpp contains now the function I coded.
I do not know yet, why adding space to the header padding make things work now.
Best
Simon
On 01 Nov 2013, at 17:01, JJ Allaire <jj.allaire at gmail.com> wrote:
> Simon,
>
> The other use was also using gcc-4.8.1 so it's got something to do with that (I don't have a local install of gcc-4.8.1 so can't repo offhand). If you are running compileAttributes inside RStudio it will run in a separate process. If not then I don't know of any significant difference between calling sourceCpp and compileAttributes.
>
> J.J.
>
>
> On Fri, Nov 1, 2013 at 11:19 AM, Simon Zehnder <szehnder at uni-bonn.de> wrote:
> Point landing J.J.!
>
> I already compiled a new R when Mavericks came out with a newly installed a gcc-4.8.2, that I can load via environment modules. I also installed the Xcode Command Line Tools for Mavericks.
>
> I now reinstalled Rcpp with the gcc-4.8.2 and threw away all object and shared-object files in my /src/ folder of my package. The problem remains. Is there something special I can look for in my Makeconf file? What is so different about ‘compileAttributes’ in contrast to ‘sourceCpp’ or a usual package compilation via R CMD INSTALL? Does compileAttributes uses some additional flags and/or libraries?
>
> Best
> Simon
>
>
>
> On 01 Nov 2013, at 15:56, JJ Allaire <jj.allaire at gmail.com> wrote:
>
> > Are you by any chance on OS X Mavericks? I had one other user report this specific error on Mavericks and it seemed to be related to the use of different compilers (and thus different heaps) within the same compilation (there is exposure to this with the changes made by Apple to the toolchain in Mavericks).
> >
> > J.J.
> >
> >
> > On Fri, Nov 1, 2013 at 10:01 AM, Simon Zehnder <szehnder at uni-bonn.de> wrote:
> > Dear Rcpp::Users and Rcpp::Devels,
> >
> > I get a weird exception when I try to compile an attribute in one of my packages:
> >
> > compileAttributes("/Users/simonzehnder/git/mmstruct/mmstruct/")
> > R(6256,0x7fff79ad9310) malloc: *** error for object 0x7fff7ac48330: pointer being freed was not allocated
> > *** set a breakpoint in malloc_error_break to debug
> > Abort trap: 6
> >
> > If I instead use the sourceCpp function all works fine:
> >
> > sourceCpp("/Users/simonzehnder/git/mmstruct/mmstruct/src/testing.cpp”)
> > testfunction_cc(c(0,0,0), list(trades = rnorm(10), T = 360))
> > [1] 0.000000e+00 3.509927e-05 1.169976e-05
> >
> > The function in my file is actually pretty simple (and its the only one):
> >
> > #include<Rcpp.h>
> >
> > // [[Rcpp::export]]
> >
> > Rcpp::NumericVector testfunction_cc(Rcpp::NumericVector par,
> > Rcpp::List list)
> > {
> > const unsigned int K = par.size();
> > Rcpp::NumericVector trades = list["trades"];
> > const unsigned int T = list["T"];
> > double tmp = mean(trades)/T;
> > std::vector<double> startp(K);
> > startp[0] = 0.0;
> > startp[1] = tmp * 0.75/2;
> > startp[2] = tmp * 0.25/2;
> >
> > return Rcpp::wrap(startp);
> > }
> >
> > At this moment I am a little perplexed. Where should I search for a possible error? What are things to try out?
> >
> > Best
> >
> > Simon
> >
> > _______________________________________________
> > 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
> >
>
>
More information about the Rcpp-devel
mailing list