rquantlib icon indicating copy to clipboard operation
rquantlib copied to clipboard

Installation Error on Mac

Open daniel1124 opened this issue 9 years ago • 5 comments

I'm trying to install RQuantLib on mac, but have some issues. Here are the steps I followed:

I first installed boost and QuantLib by following the official instructions http://quantlib.org/install/macosx.shtml The make process used Apple default clang complier.

I then go to Rstudio and try to install RQuantLib. It complained about '-fopenmp' not supported, which is understandable. So I then installed gcc-7 by brew install gcc

Then I modified ~/.R/MakeVars and added the following:

CC=gcc-7
CXX=g++-7

Then I tried to install RQuantLib again. The process went on for a few mins (with a lot of warnings on syntax, etc), and finally it gives the following error:

installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs
** R
** data
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs/RQuantLib.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs/RQuantLib.so, 6): Symbol not found: __ZN8QuantLib13MultiStepSwap12nextTimeStepERKNS_10CurveStateERSt6vectorImSaImEERS4_IS4_INS_23MarketModelMultiProduct8CashFlowESaIS9_EESaISB_EE
  Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs/RQuantLib.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs/RQuantLib.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib’
Warning in install.packages :
  installation of package ‘RQuantLib’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/fw/678zkqyd6b99rlzr6pydq71dvhrx3y/T/RtmpbsLRh6/downloaded_packages’

I don't quite understand the error message

Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs/RQuantLib.so': dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQuantLib/libs/RQuantLib.so, 6): Symbol not found: __ZN8QuantLib13MultiStepSwap12nextTimeStepERKNS_10CurveStateERSt6vectorImSaImEERS4_IS4_INS_23MarketModelMultiProduct8CashFlowESaIS9_EESaISB_EE

  1. Is this because I installed boost and QuantLib using Apple clang, and then RQuantLib using gcc-7?

  2. Is there a way to uninstall QuantLib and boost so that it gets complied by gcc-7?

  3. is there a way to upgrade clang so it supports -fopenmp?

daniel1124 avatar Nov 10 '17 01:11 daniel1124

Yes, quantlib and RQuantLib need to be compiled with gcc. The error you are seeing is the mismatch in the way the two compilers name objects. You can't mix object libraries from different compilers. Rebuild quantlib.

tleitch avatar Nov 10 '17 01:11 tleitch

Thank you @tleitch! Do you mind to share more detailed instruction on how exactly (step by step) to build boost and quantlib, specifying gcc-7 and g++-7 as the complier?

daniel1124 avatar Nov 10 '17 01:11 daniel1124

Review this link. You will need to update the library versions to match current: http://quantlib.org/install/macosx.shtml

Also see this thread: https://github.com/eddelbuettel/rquantlib/issues/80

tleitch avatar Nov 10 '17 01:11 tleitch

This https://github.com/eddelbuettel/rquantlib/wiki/RQuantLib worked. Thanks!

daniel1124 avatar Nov 10 '17 02:11 daniel1124

Ok, I guess we can close this.

eddelbuettel avatar Jan 07 '18 21:01 eddelbuettel