<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi, </div><div><br></div><div>You need to embed R and load Rcpp, otherwise this won’t work. </div><div><br></div><div>You can do this either from scratch. See <a href="http://cran.r-project.org/doc/manuals/R-exts.html#Embedding-R-under-Unix_002dalikes">http://cran.r-project.org/doc/manuals/R-exts.html#Embedding-R-under-Unix_002dalikes</a></div><div>Or you can use RInside. </div><div><br></div><div>Romain</div><div><br></div><div><div>Le 18 déc. 2013 à 12:12, Florian Oswald <<a href="mailto:florian.oswald@gmail.com">florian.oswald@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi All,<div><br></div><div>I have a C++ class that I build and test without the help of Rcpp. </div><div><br></div><div>I use Rcpp as an interface, inputting and outputting data from and to the class. I'm stuck at the outputter. Ideally I would like to have this at the end of my program:</div>

<div><br></div><div>Rcpp::List Results = MyClass.ExportToR();</div><div><br></div><div>where ExportToR is a method that creates an Rcpp::List from members of MyClass. However, I'm unable to use components of Rcpp.h in my code; In particular, I'm unable to make this toy example work:</div>

<div><br></div><div><div>#include <iostream></div><div>#include <cstdlib></div><div>#include <blitz/array.h></div><div>#include <Rcpp.h></div><div>#include <R.h></div><div><br></div><div>using namespace std;</div>

<div><br></div><div>int main(int argc, char *argv[])</div><div>{</div><div><span class="" style="white-space:pre">    </span>   Rcpp::IntegerVector d;</div><div><br></div><div><span class="" style="white-space:pre">    </span>   // Rcpp::List L; want to use</div>

<div><span class="" style="white-space:pre">    </span>   // L to output results to R.</div><div><br></div><div><span class="" style="white-space:pre">      </span>  return EXIT_SUCCESS;</div><div>}</div></div><div><br></div><div>

I compile it with</div><div><br></div><div>llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -W -I/usr/local/include -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include" -L"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/lib/" -L"/Library/Frameworks/R.framework/Versions/3.0/Resources/lib" export.cpp -lRcpp -lR -o  export<br>

</div><div><br></div><div>which compiles, but produces a segfault.</div><div><br></div><div>Thanks for any help!</div><div><br></div><div>Florian</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br>
</div>
<div><br></div></div>
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</blockquote></div><br></body></html>