Follow the instructions here to install Quantlib.
Make especially sure that you use the --with-intraday
flag for QuantLib.
The default MacOS clang++ for High Sierra does not include support for OpenMP, so you'll need to install a version that does and then set R to use it for compiling libraries.
First run brew update
to make sure you have the most up to date formulae. After that, run: brew install --with-toolchain llvm
. As of the time of writing, this will install llvm-6.0.0. This will vary as new versions are released.
This will compile and take some considerable time, roughly ~90 minutes on a 2017 Macbook Pro.
Homebrew by default does not add the newly installed clang to your path, in preference to the system version. This is a good thing that avoids conflicts. R includes a mechanism for specifying a non-system compiler that works around this. Create a file in the directory ~/.R/
called Makevars
, i.e. from the terminal:
mkdir ~/.R
touch Makevars
In that file, add the following lines with one substitution explained below:
CC=/usr/local/opt/llvm/bin/clang
CXX=/usr/local/opt/llvm/bin/clang++
CXX11=$CXX
CXX14=$CXX
CXX17=$CXX
CXX1X=$CXX
LDFLAGS=-L/usr/local/opt/llvm/lib
You will need to add the appropriate prefix before bin
and lib
to make all of this work. You can get this for the version of llvm you installed by typing: brew --prefix llvm
. Change everything before /bin/
in the CC
, CXX
, and LD
lines with your result for this command.
Now you should be able to install R quantlib using OpenMP and the command provided in the link above via the R console:
install.packages("RQuantLib", configure.args = "--with-boost-include=/usr/local/include/ --with-boost-lib=/usr/local/lib/", type = "source")
`