[This article was first published on FOSS Trading, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Before you start, note that there is now a Windows binary of RQuantLib is available on CRAN.
Due to a change in how R-2.12.0 is built, CRAN maintainers could no longer provide a Windows binary of RQuantLib with the QuantLib library they had been using. I decided to try and build an updated QuantLib library from source, which would allow me (and them) to build the current RQuantLib.
Instructions for Getting Started with QuantLib and MinGW from Scratch by Terry August (found in QuantLib FAQ 3.2) were incredibly valuable. Thanks to Dirk Eddelbuettel for helpful guidance and pointers while I was working through this exercise, and for useful comments on this blog post.
Here are the steps I took. You will need to modify the paths to suit your particular setup.
- Download and install Rtools.
- Download and install MinGW.
- Download boost (I used boost_1_42_0.tar.gz)
unzip to c:/R/cpp/boost_1_42_0
We only need the headers, so there’s nothing to install. - Download QuantLib (I used QuantLib-1.0.1.zip)
unzip to c:/R/cpp/QuantLib-1.0.1 - Install Quantlib. The make and make install commands are going to take quite some time. I think they took about 2 hours on my 3.4Ghz system. Let’s get started. Open a msys command line and run:
set PATH=c:/MinGW/bin:$PATH
cd c:/R/cpp
mkdir lib include
cd QuantLib-1.0.1
configure –with-boost-include=c:/R/cpp/boost_1_42_0 –prefix=c:/R/cpp
make
make install
cd c:/R/cpp/lib
cp libQuantLib.a libQuantLib.a.bak
strip –strip-unneeded libQuantLib.a - Download the RQuantlib source (I used RQuantLib_0.3.4.tar.gz)
unzip it to c:/R/cpp/RQuantLib - Open c:/R/cpp/RQuantLib/src/Makevars.win and ensure
PKG_LIBS=$(RCPP_LDFLAGS) -L$(QUANTLIB_ROOT)/lib -lQuantLib - Make the following directories:
c:/R/cpp/QuantLibBuild/boost
c:/R/cpp/QuantLibBuild/ql
c:/R/cpp/QuantLibBuild/lib
then copy:
c:/R/cpp/boost_1_42_0/boost to c:/R/cpp/QuantLibBuild/boost
c:/R/cpp/include/ql to c:/R/cpp/QuantLibBuild/ql
c:/R/cpp/lib/libQuantLib.a to c:/R/cpp/QuantLibBuild/lib/libQuantLib.a - Now you should be able to build RQuantLib via:
set QUANTLIB_ROOT=c:/R/cpp/QuantLibBuild
R CMD INSTALL RQuantLib_0.3.4.tar.gz
If you just want to use my build, you can install this RQuantLib_0.3.4 Windows binary.
To leave a comment for the author, please follow the link and comment on their blog: FOSS Trading.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.