<p dir="ltr">Maybe you need to set some flag in NAMESPACES to ask the package to load required libraries.</p>
<p dir="ltr">Hope that help.</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey again,<br>
<br>
I built the default Rcpp.package.skeleton rcpp_hello_world to take in<br>
strings and it worked fine. My problems seem to be from the libraries<br>
themselves. I recompiled the libraries that I could to be shared<br>
libraries and now the package builds the .so file, but I still get an<br>
error when checking the package.<br>
<br>
Error in dyn.load(file, DLLpath = DLLpath, ...) :<br>
  unable to load shared object<br>
  '/home/jrussell/src/C++/NLP/RDGGDriver/SantosDartmouth.Rcheck/SantosDartmouth/libs/SantosDartmouth.so':<br>
    liblink_4_1b.so: cannot open shared object file: No such file or directory<br>
<br>
The library liblink_4_1b.so is link grammar with slight modifications to<br>
work with C++ code instead of C code and doesn't have an R package. I<br>
have placed all libs in the src directory of the package, and they can<br>
all be found at build time, and the .so file seems to be correctly<br>
built, but then when it is checked, it seems not to use the same<br>
ldflags that it uses when building (PKG_LIBS). Is this something that I<br>
need to set separately? I have tried ??Makevars and google searches for<br>
"R Makevars" and "external libraries Rcpp" and not found much. Are there<br>
any concrete examples of packaging external libraries inside of R<br>
packages? I have gone through all of the vignettes that I could find and<br>
can't seem to find anything about including pre-built .so files in<br>
packages. I suspect this is to keep source-only, but the libraries are<br>
not all mine and I don't have this option available.<br>
<br>
Thanks!<br>
<br>
Jacob Russell<br>
<br>
P.S. Time-To-Response on this mailing list is probably the best that I<br>
have ever seen on a mailing list. Congrats!<br>
<br>
On Fri, Aug 16, 2013 at 12:52:37PM -0500, Dirk Eddelbuettel wrote:<br>
><br>
> On 16 August 2013 at 13:45, <a href="mailto:jacob.a.russell.th@dartmouth.edu">jacob.a.russell.th@dartmouth.edu</a> wrote:<br>
> | Hello,<br>
> |<br>
> | I am trying to build a package but I have quite a few dependencies. As such, I<br>
> | have modified Makevars to be (I don't like backticks because I find them too<br>
> | similar to single quotes):<br>
> |<br>
> | PKG_LIBS = $($(R_HOME)/bin/Rscript -e 'Rcpp:::LdFlags()') -L. -llink_4_1b -lDGG -lSTR -lDLL -lAF -lmy_std -lm<br>
> | PKG_CPPFLAGS=-I. -g<br>
> |<br>
> | Which seems to compile when my R wrapper is (incorrectly):<br>
> |<br>
> | RcppExport SEXP getDocGraph(std::string input){<br>
> |<br>
> |     std::string testStr = input;<br>
> |     std::string output=getDG(testStr);<br>
> |     return(Rcpp::wrap(output));<br>
> | }<br>
> |<br>
> | but then it gives me a segmentation fault because it cannot access the<br>
> | underlying character array (or general object) passed in by R.<br>
> |<br>
> | Then if I change the function protoype to:<br>
> |<br>
> | RcppExport SEXP getDocGraph(SEXP input){<br>
> |<br>
> |     std::string testStr = Rcpp::as<std::string>(input);<br>
> |     std::string output=getDG(testStr);<br>
> |     return(Rcpp::wrap(output));<br>
> | }<br>
> |<br>
> | it seems to compile, but when I go to check the package, the .Rcheck directory<br>
> | gives me an error:<br>
> |<br>
> | ** testing if installed package can be loaded<br>
> | Error in dyn.load(file, DLLpath = DLLpath, ...) :<br>
> |   unable to load shared object ...<packagename>.so':<br>
> |<br>
> | and the .so file is not in the tgz package, but no error was given during<br>
> | compilation.<br>
> |<br>
> | Any help is greatly appreciated.<br>
><br>
> Simplify.<br>
><br>
> I would start by removing your six additional libraries and convince myself<br>
> that accessing a string via Rcpp works (and as our unit tests do that a lot,<br>
> you would have to be in a very unusual situation to not have it work).<br>
><br>
> Once that works, add your libraries. If and when things break again, examine<br>
> the differences.<br>
><br>
> Dirk<br>
><br>
> --<br>
> Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
_______________________________________________<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>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</div>