Quantlib-SWIG 1.12.x for Python error, missing Quantlib/quantlib_wrap.cpp in windows

432 views Asked by At

I downloaded both Quantlib-SWIG 1.12.x and Quantlib 1.12.x from github. Quantlib is compiled without and problems. The examples ran normally. However, when run python setup.py build, there is an error indicating missing quantlib_wrap.cpp. Where to download the proper quantlib_wrap.cpp for this version or this error is related to something else? Here is the messages I got from this build.

C:\Users\Public\3rdParty\Libraries\QuantLib-SWIG-1.12.x\Python>python setup.py build
running build
running build_py
file QuantLib\QuantLib.py (for module QuantLib.QuantLib) not found
file QuantLib\QuantLib.py (for module QuantLib.QuantLib) not found
running build_ext
building 'QuantLib._QuantLib' extension
C:\Users\U435169\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX -Id:\packages\Python27\include -Id:\packages\Python27\PC -IC:\Users\Public\3rdParty\Libraries\QuantLib-master /TpQuantLib/quantlib_wrap.cpp /Fobuild\temp.win32-2.7\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /bigobj /MD
quantlib_wrap.cpp
c1xx : fatal error C1083: Cannot open source file: 'QuantLib/quantlib_wrap.cpp': No such file or directory
error: command 'C:\\Users\\U435169\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
1

There are 1 answers

1
Luigi Ballabio On

quantlib_wrap.cpp is generated by SWIG using the sources in the repository. If you have SWIG installed, you can generate it (see https://www.quantlib.org/install/windows-python.shtml); but if you don't have plans to modify the sources, I suggest that you either:

  • instead of cloning the repo from GitHub, download an official release (see https://www.quantlib.org/download.shtml); released sources include quantlib_wrap.cpp;

  • or better yet, as suggested in the install page linked above, try running

    pip install QuantLib-Python
    

    to see if a precompiled Python module is available from PyPI. If that succeeds, you'll be set without having to compile the thing yourself.