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

Dirk Eddelbuettel edd at debian.org
Wed Oct 29 04:09:44 CET 2014


On 29 October 2014 at 03:36, Benjamin J. J. Voigt wrote:
| Hello,
| 
| apologies if this is the wrong place to discuss the matter. The relationship of

It is very much the place!

| 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).

Maybe. I don't have access to an OS X machine. It works for me; and I am sure
we can work out where OS X gets hung up.
 
| 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

That smells like the old pre-Mavericks XCode / post-Mavericks XCode to me,
but I may be wrong.

Can you otherwise build via 'R CMD INSTALL ...' and friends?

Does Rcpp pass its "minimally sufficient test", eg doing    evalCpp("2 + 2")  ?

| 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.

I am sort of in the middle of this, but we know where each the pieces comes
from.

R gets a few from its Makeconf -- defined and written when it is build.
Others come from our package.  We have control over this and can fix it.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rquantlib-devel mailing list