[Rquantlib-devel] Error calling QuantLib functions through Rcpp/[[Rcpp::depends(RQuantLib)]]

Benjamin J. J. Voigt bvoigt at gmail.com
Wed Oct 29 03:36:42 CET 2014


Hello,

apologies if this is the wrong place to discuss the matter. The
relationship of Rcpp and RQuantLib is not entirely clear to me. From the
preceding discussion I believe the issue is rather with RQuantLib then with
Rcpp.

when trying to access QuantLib functions using Rcpp through the following
code it seems to complain about files that are not found. Things work
smoothly on the command line (outside R) if I remove the offending lines
from the clang++ invocation. This may just be a Mac issue (I have not tried
this in a Linux environment yet).

The question is: how do I change the clang++ call to exclude the offending
directories in the hope that things will work afterwards. Or, alternative,
if clang++ runs through on the command line, how do I proceed inside R to
use the compiled code?

CPP-Code (in file: QuantLibTest.cpp):
#include <ql/quantlib.hpp>
#include <Rcpp.h>

using namespace Rcpp;

// [[Rcpp::depends(RQuantLib)]]

// [[Rcpp::export]]
double timesTwo(double x) {
  QuantLib::Calendar myCal = QuantLib::UnitedKingdom();
  QuantLib::Date newYearsEve(31, QuantLib::Dec, 2008);
  QuantLib::Rate zc3mQuote = x;
  return zc3mQuote * 2;
}


R-Command:
sourceCpp(“/temp/QuantLibTest.cpp")


R-Error:
ld: warning: directory not found for option
'-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/x86_64'
ld: warning: directory not found for option
'-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [sourceCpp_41769.so] Error 1
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-DRQuantLib_Plugin -I/opt/local/include -I/opt/local/include
 -I/usr/local/include
 -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include"
-I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RQuantLib/include"
   -fPIC  -mtune=core2 -g -O2  -c QuantLibTest.cpp -o QuantLibTest.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined
dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib
-L/usr/local/lib -o sourceCpp_41769.so QuantLibTest.o -L/opt/local/lib
-L/opt/local/lib -lQuantLib -L/Library/Frameworks/R.framework/Resources/lib
-lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas
-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64
-L/usr/local/lib/x86_64 -L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3
-lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
-Wl,CoreFoundation
Error in sourceCpp(“/temp/QuantLibTest.cpp") :
  Error 1 occurred building shared library.

If I remove the "-L/usr/locale/..." references that throw the warnings
above on the command line things run without an issue, if they are not
removed the same error occurs as when run inside R.

Any ideas are welcome and I am happy to supply additional information.

Kind Regards,
Ben

-- 
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rquantlib-devel/attachments/20141029/c9d251d0/attachment.html>


More information about the Rquantlib-devel mailing list