eddelbuettel / rquantlib

R interface to the QuantLib library
120 stars 50 forks source link

Error in calendars.cpp while installing RQuantLib debian 10 docker container. #171

Closed mg64ve closed 2 years ago

mg64ve commented 2 years ago

Hello, I am getting the following error during installation:

calendars.cpp: In function ‘boost::shared_ptr<QuantLib::Calendar> getCalendar(const string&)’:
calendars.cpp:76:24: error: expected type-specifier
         pcal.reset(new QuantLib::France(QuantLib::France::Settlement));

the following is the full error log:

> install.packages('RQuantLib',dependencies=TRUE, repos='http://cran.rstudio.com/')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RQuantLib_0.4.16.tar.gz'
Content type 'application/x-gzip' length 190801 bytes (186 KB)
==================================================
downloaded 186 KB

* installing *source* package ‘RQuantLib’ ...
** package ‘RQuantLib’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for R... yes
checking for quantlib-config... yes
checking for Boost development files... yes
checking for minimal Boost version... yes
configure: creating ./config.status
config.status: creating src/Makevars
Configured RQuantlib 0.4.16
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c affine.cpp -o affine.o
affine.cpp: In function ‘void calibrateModel2(const boost::shared_ptr<QuantLib::ShortRateModel>&, const std::vector<boost::shared_ptr<QuantLib::BlackCalibrationHelper> >&, QuantLib::Real, Rcpp::NumericVector&, Rcpp::NumericVector&, Rcpp::NumericVector&)’:
affine.cpp:33:53: warning: ‘QuantLib::CalibrationHelper’ is deprecated [-Wdeprecated-declarations]
     std::vector<QuantLib::ext::shared_ptr<QuantLib::CalibrationHelper>>
                                                     ^~~~~~~~~~~~~~~~~
In file included from /usr/include/ql/models/model.hpp:32,
                 from /usr/include/ql/pricingengines/latticeshortratemodelengine.hpp:28,
                 from /usr/include/ql/experimental/callablebonds/treecallablebondengine.hpp:28,
                 from /usr/include/ql/experimental/callablebonds/all.hpp:9,
                 from /usr/include/ql/experimental/all.hpp:8,
                 from /usr/include/ql/quantlib.hpp:46,
                 from ../inst/include/rquantlib_internal.h:23,
                 from affine.cpp:23:
/usr/include/ql/models/calibrationhelper.hpp:116:36: note: declared here
     typedef BlackCalibrationHelper CalibrationHelper;
                                    ^~~~~~~~~~~~~~~~~
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c asian.cpp -o asian.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c barrier_binary.cpp -o barrier_binary.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bermudan.cpp -o bermudan.o
bermudan.cpp: In function ‘void calibrateModel(const boost::shared_ptr<QuantLib::ShortRateModel>&, const std::vector<boost::shared_ptr<QuantLib::BlackCalibrationHelper> >&, QuantLib::Real, Rcpp::NumericVector&, Rcpp::NumericVector&, Rcpp::NumericMatrix&)’:
bermudan.cpp:33:53: warning: ‘QuantLib::CalibrationHelper’ is deprecated [-Wdeprecated-declarations]
     std::vector<QuantLib::ext::shared_ptr<QuantLib::CalibrationHelper> >
                                                     ^~~~~~~~~~~~~~~~~
In file included from /usr/include/ql/models/model.hpp:32,
                 from /usr/include/ql/pricingengines/latticeshortratemodelengine.hpp:28,
                 from /usr/include/ql/experimental/callablebonds/treecallablebondengine.hpp:28,
                 from /usr/include/ql/experimental/callablebonds/all.hpp:9,
                 from /usr/include/ql/experimental/all.hpp:8,
                 from /usr/include/ql/quantlib.hpp:46,
                 from ../inst/include/rquantlib_internal.h:23,
                 from bermudan.cpp:23:
/usr/include/ql/models/calibrationhelper.hpp:116:36: note: declared here
     typedef BlackCalibrationHelper CalibrationHelper;
                                    ^~~~~~~~~~~~~~~~~
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bonds.cpp -o bonds.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -I/usr/include -fopenmp -fpermissive -I../inst/include -I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c calendars.cpp -o calendars.o
calendars.cpp: In function ‘boost::shared_ptr<QuantLib::Calendar> getCalendar(const string&)’:
calendars.cpp:76:24: error: expected type-specifier
         pcal.reset(new QuantLib::France(QuantLib::France::Settlement));
                        ^~~~~~~~
calendars.cpp:78:24: error: expected type-specifier
         pcal.reset(new QuantLib::France(QuantLib::France::Exchange));
                        ^~~~~~~~
make: *** [/usr/lib/R/etc/Makeconf:171: calendars.o] Error 1
ERROR: compilation failed for package ‘RQuantLib’
* removing ‘/usr/local/lib/R/site-library/RQuantLib’

The downloaded source packages are in
    ‘/tmp/Rtmpv7O8OF/downloaded_packages’
Warning message:
In install.packages("RQuantLib", dependencies = TRUE, repos = "http://cran.rstudio.com/") :
  installation of package ‘RQuantLib’ had non-zero exit status
> 
> 
eddelbuettel commented 2 years ago

What version of libquantlib0-dev do you have (or if you installed from source, what version of QuantLib did you use) ?

What compiler version is that?

Note that Debian 10 is old-stable. Why do you pick that? At CRAN, RQuantLib looks fine on all platforms (which are more current that old-stable):

image

I just upgraded QuantLib itself to 1.27 and RQuantLib works fine with it.

mg64ve commented 2 years ago

Hi @eddelbuettel , I have:

libquantlib0-dev (1.15-1)
gcc version 8.3.0 (Debian 8.3.0-6) 

I do not think there is any particular reason I am using Debian 10. I have started using the following image few months back:

FROM python:3.9-slim-buster

Do you recommend me to upgrade?

eddelbuettel commented 2 years ago

QuantLib 1.15 is seriously antiquated -- Feb 2019 or 3 1/2 years old.

You are free to choose any container you like and that suits you, but if you want to use current software from CRAN you may need to pay closer attention to a current container.

You may notice that this very repo even has a directory docker/ with a container I use for continuous integration testing, and then a convenience container that installs RQuantLib for easiest deployment. You could start from those -- or you could stick with your slim-buster container but you probably want an older version of QuantLib and/or RQuantLib then.

I am going to close this issue ticket as there is nothing wrong with RQuantLib. We do have a mailing for general support and discussion, feel free to join and ask there too. Thanks for your interest in RQuantLib!

eddelbuettel commented 2 years ago

So in short if you have QL from Feb 2019, then from glancing at the Archive/ dir of RQuantLib you may get 0.4.9 to work:

image

The current RQuantLib requires a more current QuantLib than you have.

mg64ve commented 2 years ago

Thanks @eddelbuettel , I am using the following and looks to be fine!

FROM python:3.9.13-bullseye

eddelbuettel commented 2 years ago

Also: sudo apt install r-cran-rquantlib gets you a premade version (current to when the distro release was cut).