OpenSourceRisk / Engine

Open Source Risk Engine
http://www.opensourcerisk.org
Other
488 stars 219 forks source link

Building ORE-SWIG OREAnalytics-Python #121

Closed rjabrazko closed 1 year ago

rjabrazko commented 1 year ago

Hi all,

After building ORE and QuantLib (and using the right version of QL 1.27.1), I try to build OREAnalytics using VS 2019, I got the following error

1>------ Build started: Project: _OREAnalytics, Configuration: Release x64 ------
1>oreanalyticsPYTHON_wrap.cxx
1>C:\ore\QuantLib\ql/termstructures/inflationtermstructure.hpp(347,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
1>C:\ore\QuantLib\ql/experimental/inflation/cpicapfloortermpricesurface.hpp(89,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
1>C:\ore\QuantLib\ql/experimental/inflation/yoycapfloortermpricesurface.hpp(58,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
1>C:\ore\QuantLib\ql/termstructures/yield/drifttermstructure.hpp(64,50): warning C4996: 'QuantLib::DriftTermStructure': was declared deprecated
1>C:\ore\QuantLib\ql/termstructures/yield/drifttermstructure.hpp(86,57): warning C4996: 'QuantLib::DriftTermStructure': was declared deprecated
1>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(5315,1): fatal error C1189: #error:  using an old version of QuantLib, please update
1>Done building project "_OREAnalytics.vcxproj" -- FAILED.
2>------ Skipped Build: Project: ALL_BUILD, Configuration: Release x64 ------

Which clearly indicates that I am using an old version of QuantLib, after checking "oreanalyticsPYTHON_wrap.cxx" it is clearly indicating

#include <ql/quantlib.hpp>

#if QL_HEX_VERSION < 0x01280000
    #error using an old version of QuantLib, please update
#endif

a version of QL 1.28, which is not used here Any ideas what might be wrong here? I downloaded ORE QuantLib directly from submodule

Thanks

Reda

rjabrazko commented 1 year ago

Hi

I think I have been using the wrong version of QuantLib-SWIG, I downloaded a version directly from here (https://github.com/OpenSourceRisk/QuantLib-SWIG/tree/06505c33f14c98690f00b5558d1abf8310fbe79c) but now after building in VS 2019 I have the following error

2>------ Build started: Project: _OREAnalytics, Configuration: Release x64 ------
2>Swig compile C:/oreswig/OREAnalytics-SWIG/Python/../SWIG/oreanalytics.i for python
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantExt-SWIG\SWIG\qle_termstructures.i(235): warning 325: Nested struct not currently supported (RefData ignored)
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantExt-SWIG\SWIG\qle_averageois.i(81): warning 314: 'None' is a python keyword, renaming to '_None'
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantExt-SWIG\SWIG\qle_termstructures.i(218): warning 401: Nothing known about base class 'Observer'. Ignored.
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantLib-SWIG\SWIG\swap.i(53): warning 509: Overloaded method Swap::Swap(std::vector< Leg,std::allocator< Leg > > const &,std::vector< bool,std::allocator< bool > > const &) effectively ignored,
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantLib-SWIG\SWIG\swap.i(51): warning 509: as it is shadowed by Swap::Swap(std::vector< ext::shared_ptr< CashFlow >,std::allocator< ext::shared_ptr< CashFlow > > > const &,std::vector< ext::shared_ptr< CashFlow >,std::allocator< ext::shared_ptr< CashFlow > > > const &).
2>Building Custom Rule C:/oreswig/OREAnalytics-SWIG/Python/CMakeLists.txt
2>oreanalyticsPYTHON_wrap.cxx
2>C:\ore\QuantLib\ql/termstructures/inflationtermstructure.hpp(347,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
2>C:\ore\QuantLib\ql/experimental/inflation/cpicapfloortermpricesurface.hpp(89,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
2>C:\ore\QuantLib\ql/experimental/inflation/yoycapfloortermpricesurface.hpp(58,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
2>C:\ore\QuantLib\ql/termstructures/yield/drifttermstructure.hpp(64,50): warning C4996: 'QuantLib::DriftTermStructure': was declared deprecated
2>C:\ore\QuantLib\ql/termstructures/yield/drifttermstructure.hpp(86,57): warning C4996: 'QuantLib::DriftTermStructure': was declared deprecated
2>C:\boost_1_75_0\boost/bind.hpp(41): message : The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.
2>C:\boost_1_75_0\boost/detail/iterator.hpp(13): message : This header is deprecated. Use <iterator> instead.
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(708315,114): error C2679: binary '=': no operator found which takes a right-hand operand of type 'QuantLib::Handle<QuantExt::BaseCorrelationTermStructure>' (or there is no acceptable conversion)
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(32,21): message : could be 'SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>> &SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>>::operator =(const T &)'
2>        with
2>        [
2>            Corr2DInt_T=QuantLib::BilinearInterpolation,
2>            T=QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<QuantLib::BilinearInterpolation>>
2>        ]
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(28,21): message : or       'SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>> &SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>>::operator =(const SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>> &)'
2>        with
2>        [
2>            Corr2DInt_T=QuantLib::BilinearInterpolation
2>        ]
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(708315,114): message : while trying to match the argument list '(SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>>, QuantLib::Handle<QuantExt::BaseCorrelationTermStructure>)'
2>        with
2>        [
2>            Corr2DInt_T=QuantLib::BilinearInterpolation
2>        ]
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(708375,87): error C2679: binary '=': no operator found which takes a right-hand operand of type 'QuantLib::Handle<QuantExt::BaseCorrelationTermStructure>' (or there is no acceptable conversion)
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(32,21): message : could be 'SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>> &SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>>::operator =(const T &)'
2>        with
2>        [
2>            Corr2DInt_T=QuantLib::BilinearInterpolation,
2>            T=QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<QuantLib::BilinearInterpolation>>
2>        ]
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(28,21): message : or       'SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>> &SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>>::operator =(const SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>> &)'
2>        with
2>        [
2>            Corr2DInt_T=QuantLib::BilinearInterpolation
2>        ]
2>C:\oreswig\builddir\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(708375,87): message : while trying to match the argument list '(SwigValueWrapper<QuantLib::Handle<QuantLib::BaseCorrelationTermStructure<Corr2DInt_T>>>, QuantLib::Handle<QuantExt::BaseCorrelationTermStructure>)'
2>        with
2>        [
2>            Corr2DInt_T=QuantLib::BilinearInterpolation
2>        ]
2>Done building project "_OREAnalytics.vcxproj" -- FAILED.

I don't know if the error is still linked to the version of QL and QL-SWIG, or has to do with something else?

Thanks

Reda

rkapl123 commented 1 year ago

I see exactly the same problem using cmake. I cloned the ORE project (into C:\dev\ORE\Engine) and the ORE-SWIG (into C:\dev\ORE-SWIG) freshly from the master branches and built successfully ORE using cmake, including Quantlib. Then I tried to cmake ORE-SWIG using below script that used to work.

set VSVersion="Visual Studio 16 2019"
cmake -G %VSVersion% -A x64 -DSWIG_DIR=C:\dev\swigwin\Lib -DSWIG_EXECUTABLE=C:\dev\swigwin\swig.exe -DORE:PATHNAME=C:\dev\ORE\Engine -DBOOST_ROOT=C:\dev\boost -S . -B build
cmake --build build -v --config Release

The result were the same compilation errors as above. I guess it's a mismatch of the Quantlib version in C:\dev\ORE\Engine -regards, Roland

pcaspers commented 1 year ago

Are you building a release tag? The master branches of ORE and ORE-Swig are not always aligned.

rkapl123 commented 1 year ago

No, but now I did an explicit checkout of 1.8.7.0 of ORE-SWIG (again had problems with updating the submodule Quantlib-SWIG, my settings didn't persist), but again the same compiler error: C:\dev\ORE-SWIG2\build\OREAnalytics-SWIG\Python\CMakeFiles\_OREAnalytics.dir\oreanalyticsPYTHON_wrap.cxx(708315,114): error C2679: Binärer Operator "=": Es konnte kein Operator gefunden wer den, der einen rechtsseitigen Operanden vom Typ "QuantLib::Handle<QuantExt::BaseCorrelationTermStructure>" akzeptiert (oder keine geeignete Konvertierung möglich) [C:\dev\ORE-SWIG2\build\OR EAnalytics-SWIG\Python\_OREAnalytics.vcxproj]

The referenced ORE Quantlib Submodule (master) is still the same as in the 1.8.7.0 tag.

pcaspers commented 1 year ago

Just to be sure, you did checkout ORE 1.8.7.0 as well?

rjabrazko commented 1 year ago

Ok I restarted everything from scratch, no git no clone no master branches... only using the release tag for both ORE and ORE swig After building successfully ORE with the right version of QuantLib, I built ORE SWIG with this version of QuantLib SWIG (https://github.com/OpenSourceRisk/QuantLib-SWIG/tree/06505c33f14c98690f00b5558d1abf8310fbe79c) it worked

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Release x64 ------
1>Checking Build System
2>------ Rebuild All started: Project: _OREAnalytics, Configuration: Release x64 ------
2>Swig compile C:/oreswig/OREAnalytics-SWIG/Python/../SWIG/oreanalytics.i for python
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantExt-SWIG\SWIG\qle_termstructures.i(235): warning 325: Nested struct not currently supported (RefData ignored)
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantExt-SWIG\SWIG\qle_averageois.i(81): warning 314: 'None' is a python keyword, renaming to '_None'
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantExt-SWIG\SWIG\qle_termstructures.i(218): warning 401: Nothing known about base class 'Observer'. Ignored.
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantLib-SWIG\SWIG\swap.i(53): warning 509: Overloaded method Swap::Swap(std::vector< Leg,std::allocator< Leg > > const &,std::vector< bool,std::allocator< bool > > const &) effectively ignored,
2>C:\oreswig\OREAnalytics-SWIG\Python\..\..\QuantLib-SWIG\SWIG\swap.i(51): warning 509: as it is shadowed by Swap::Swap(std::vector< ext::shared_ptr< CashFlow >,std::allocator< ext::shared_ptr< CashFlow > > > const &,std::vector< ext::shared_ptr< CashFlow >,std::allocator< ext::shared_ptr< CashFlow > > > const &).
2>Building Custom Rule C:/oreswig/OREAnalytics-SWIG/Python/CMakeLists.txt
2>oreanalyticsPYTHON_wrap.cxx
2>C:\ore\QuantLib\ql/termstructures/inflationtermstructure.hpp(347,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
2>C:\ore\QuantLib\ql/experimental/inflation/cpicapfloortermpricesurface.hpp(89,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
2>C:\ore\QuantLib\ql/experimental/inflation/yoycapfloortermpricesurface.hpp(58,14): warning C4996: 'QuantLib::InflationTermStructure::indexIsInterpolated': was declared deprecated
2>C:\ore\QuantLib\ql/termstructures/yield/drifttermstructure.hpp(64,50): warning C4996: 'QuantLib::DriftTermStructure': was declared deprecated
2>C:\ore\QuantLib\ql/termstructures/yield/drifttermstructure.hpp(86,57): warning C4996: 'QuantLib::DriftTermStructure': was declared deprecated
2>C:\boost_1_75_0\boost/bind.hpp(41): message : The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.
2>C:\boost_1_75_0\boost/detail/iterator.hpp(13): message : This header is deprecated. Use <iterator> instead.
2>   Creating library C:/oreswig/builddir/Release/_OREAnalytics.lib and object C:/oreswig/builddir/Release/_OREAnalytics.exp
2>LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
2>_OREAnalytics.vcxproj -> C:\oreswig\builddir\Release\_OREAnalytics.pyd
2>Done building project "_OREAnalytics.vcxproj".
3>------ Skipped Rebuild All: Project: ALL_BUILD, Configuration: Release x64 ------
3>Project not selected to build for this solution configuration 
========== Rebuild All: 2 succeeded, 0 failed, 1 skipped ==========

I agree with Peter the master branches of ORE and ORE swig are not always aligned I will close the issue

Reda

rjabrazko commented 1 year ago

Thank you very much Roland and Peter

Regards

Reda

rkapl123 commented 1 year ago

Same for me, I cloned both ORE and ORE-SWIG directly from the OpenSourceRisk repository, then explicitly switched both to 1.8.7.0, updated submodules (I'd suggest to change the .gitconfig to https as well for ORE-SWIG) and then built ORE and subsequently succesfully ORE-SWIG.

pcaspers commented 1 year ago

Ah yes, I will change that url as well