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.
On Wed, Sep 4, 2013 at 11:51 AM, Simon Zehnder <[email protected]> wrote: > Dear Rcpp::Users, Rcpp::Devels, > > 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. > > I am trying to use the C++ optimization library nlopt ( > http://ab-initio.mit.edu/wiki/index.php/NLopt) 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: > > ## Use the R_HOME indirection to support installations of multiple R > version > NLOPT_VERSION = 2.3 > > NLOPT_LIBS = -lm nlopt-${NLOPT_VERSION}/lib/libnlopt_cxx.a > > NLOPT_INCL = -I./nlopt-${NLOPT_VERSION}/include > > PKG_CPPFLAGS = ${NLOPT_INCL} > PKG_CFLAGS = -pipe ${NLOPT_INCL} > PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` ${NLOPT_LIBS} > > Calling 'R CMD INSTALL packageName' compiles without errors but produces > the well-known error during loading the shared library: > > Error in dyn.load(file, DLLpath = DLLpath, ...) : > unable to load shared object > '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/finmix/libs/finmix.so': > > 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_ > > 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? > > > Best > > Simon > > > _______________________________________________ > Rcpp-devel mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel >
_______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
