<div dir="ltr">Do you know of the nloptr and nloptwrap R packages based on NLopt.  The nloptr package installs the NLopt library.  Unfortunately it does not put the header files in inst/include in the source package so they will be available in the include subdirectory of the installed package.<div>
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 4, 2013 at 11:51 AM, Simon Zehnder <span dir="ltr"><<a href="mailto:szehnder@uni-bonn.de" target="_blank">szehnder@uni-bonn.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Rcpp::Users, Rcpp::Devels,<br>
<br>
I am following the ongoing discussion 'How to use external C++ libraries in R packages withRcpp' (Makevars are still one of my weaknesses) and I have a related question.<br>
<br>
I am trying to use the C++ optimization library nlopt (<a href="http://ab-initio.mit.edu/wiki/index.php/NLopt" target="_blank">http://ab-initio.mit.edu/wiki/index.php/NLopt</a>) in my package that is based on RcppArmadillo. In a first step I installed nlopt in a subfolder of the 'src' folder of my package structure (so I have '/src/nlopt-2.3'). Second, I included the header file into my source file right below '#include <RcppArmadillo.h>'. Then I set my Makevars file to:<br>

<br>
## Use the R_HOME indirection to support installations of multiple R version<br>
NLOPT_VERSION = 2.3<br>
<br>
NLOPT_LIBS = -lm nlopt-${NLOPT_VERSION}/lib/libnlopt_cxx.a<br>
<br>
NLOPT_INCL = -I./nlopt-${NLOPT_VERSION}/include<br>
<br>
PKG_CPPFLAGS = ${NLOPT_INCL}<br>
PKG_CFLAGS = -pipe ${NLOPT_INCL}<br>
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` ${NLOPT_LIBS}<br>
<br>
Calling 'R CMD INSTALL packageName' compiles without errors but produces the well-known error during loading the shared library:<br>
<br>
Error in dyn.load(file, DLLpath = DLLpath, ...) :<br>
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/finmix/libs/finmix.so':<br>
  dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/finmix/libs/finmix.so, 6): Symbol not found: __ZNSt8__detail15_List_node_base11_M_transferEPS0_S1_<br>
<br>
I find the missing symbol (using 'nm -A libnlopt_cxx.a | grep "transfer"' on the shell) in the static library of nlopt (libnlopt_cxx.a) to which I link in the Makevars, but I do not know yet, how I have to modify the Makevars to include also the static library of nlopt into the shared library of my package. Does anyone have a suggestion how to do it?<br>

<br>
<br>
Best<br>
<br>
Simon<br>
<br>
<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>
</blockquote></div><br></div>