enthought / pyql

Cython QuantLib wrappers
Other
1k stars 196 forks source link

PyQL building issues #86

Open mtrstudio opened 9 years ago

mtrstudio commented 9 years ago

Hi, I followed all the steps in the documents, and I also checked previous issues some other guys may have had, but still I can't build the library correctly, here's the messages I got from building.

setting.hpp is patched, quantlib is built, def generated, then quantlib built again. Then I add folders containing .lib, .dll and folders containing .obj to the PATH I also modified setup.py so that all directories can be correctly found, then I built with MSVC. Still got the errors below...

Could you tell me are there any steps I went wrong? Thanks~


C:\Users...\Documents\GitHub\pyql>cmd.exe Microsoft Windows Version 6.3.9600 2013 Microsoft Corporation. All rights reserved.

C:\Users...\Documents\GitHub\pyql>python setup.py build --compiler=msvc C:\Users...\Documents\GitHub\pyql setup.py C:\Python27\lib\distutils\extension.py:133: UserWarning: Unknown Extension optio ns: 'cython_directives' warnings.warn(msg) missing cimport in module 'quantlib.time': quantlib\instruments\credit_default_s wap.pyx missing cimport in module 'quantlib.pricingengines': quantlib\instruments\credit _default_swap.pyx missing cimport in module 'quantlib.pricingengines': quantlib\instruments\option .pyx running build running build_py running build_ext building 'quantlib.cashflow' extension C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe /c /nolo go /Ox /MD /W3 /GS- /DNDEBUG -DWIN32 -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX -DWINNT -D_WINDLL -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_SCL_S ECURE_NO_WARNINGS -IE:\Projects\QuantLib-1.5 -ID:\Modules\boost -I. -I./cpp_l ayer -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -I C:\Python27\PC /Tpquantlib\cashflow.cpp /Fobuild\temp.win-amd64-2.7\Release\quan tlib\cashflow.obj /GR /FD /Zm250 /EHsc cashflow.cpp c:\python27\include\pymath.h(22) : warning C4273: 'round' : inconsistent dll lin kage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(51 6) : see previous definition of 'round' C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xtgmath.h(206) : warning C4273: 'round' : inconsistent dll linkage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(51 6) : see previous definition of 'round' C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\link.exe /DLL / nologo /INCREMENTAL:NO /LIBPATH:E:\Projects\QuantLib-1.5\build\vc120\Win32\Re lease /LIBPATH:E:\Projects\QuantLib-1.5\lib /LIBPATH:. /LIBPATH:C:\Python27\l ibs /LIBPATH:C:\Python27\PCbuild\amd64 QuantLib.lib /EXPORT:initcashflow build\t emp.win-amd64-2.7\Release\quantlib\cashflow.obj /OUT:build\lib.win-amd64-2.7\qua ntlib\cashflow.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\quantlib\cashflow.li b /MANIFESTFILE:build\temp.win-amd64-2.7\Release\quantlib\cashflow.pyd.manifest /subsystem:windows cashflow.obj : warning LNK4197: export 'initcashflow' specified multiple times; using first specification Creating library build\temp.win-amd64-2.7\Release\quantlib\cashflow.lib and o bject build\temp.win-amd64-2.7\Release\quantlib\cashflow.exp cashflow.obj : error LNK2019: unresolved external symbol "public: cdecl QuantL ib::Date::Date(void)" (??0Date@QuantLib@@QEAA@XZ) referenced in function "struct _object * cdecl pyx_pf_8quantlib_8cashflow_8CashFlow_4date___get(struct _ _pyx_obj_8quantlib_8cashflow_CashFlow *)" (?pyx_pf_8quantlib_8cashflow_8CashFl ow4dateget__@@YAPEAU_object@@PEAU__pyx_obj_8quantlib_8cashflow_CashFlow@@@Z)

cashflow.obj : error LNK2019: unresolved external symbol "public: cdecl QuantL ib::SimpleCashFlow::SimpleCashFlow(double,class QuantLib::Date const &)" (??0Sim pleCashFlow@QuantLib@@QEAA@NAEBVDate@1@@Z) referenced in function "int _cdecl _pyx_pf_8quantlib_8cashflow_14SimpleCashFlow___init(struct pyx_obj_8quantlib _8cashflow_SimpleCashFlow ,double,struct __pyx_obj_8quantlib_4time_4date_Date )" (?__pyx_pf_8quantlib_8cashflow_14SimpleCashFlow___init@@YAHPEAUpyx_obj_8q uantlib_8cashflow_SimpleCashFlow@@NPEAUpyx_obj_8quantlib_4time_4date_Date@@@Z)

build\lib.win-amd64-2.7\quantlib\cashflow.pyd : fatal error LNK1120: 2 unresolve d externals error: command 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\ amd64\link.exe' failed with exit status 1120

dpinte commented 9 years ago

@mtrstudio multiple things:

  1. can you verify that the missing simbol exists in the .def file?
    • ??0Date@QuantLib@@QEAA@XZ
    • ??0SimpleCashFlow@QuantLib@@QEAA@NAEBVDate@1@@Z (are you sure you point to the latest version of the generate .lib file from MSVC?)
  2. you're can't build QL with MSC 2012 and planning to use it with Python 2.7. Python 2.7 "can only use" extensions built with MSVC 2008.
charles-peter commented 9 years ago

Hey I actually just ran into the same exact error. I compiled QL in Visual Studio 2013 express are you saying I'll need to compile in an older Microsoft compiler? i.e. VS2008

dpinte commented 9 years ago

@charles-peter yes, you should be either using VS2008 or the free C++ compiler for Python 2.7: http://www.microsoft.com/en-us/download/details.aspx?id=44266

mtrstudio commented 9 years ago

Hey, indeed I can't find

  1. ??0Date@QuantLib@@QEAA@XZ
  2. ??0SimpleCashFlow@QuantLib@@QEAA@NAEBVDate@1@@Z in the .def file (which is of size 42257K), could it be that something is missing when I generate the .def file. Which object files after building quantlib are responsible for the two symbols?

It seems the .def is not properly generated, I have 288340 lines in .def, subtracting the first two lines which are LIBRARY "QuantLib" EXPORTS then there are 288338 functions are generated in .def, is that right?

By the way I am using quantlib-1.5, I saw some other guys in previous posts were also using this version.

dpinte commented 9 years ago

Yes, that looks like a .def file generation issue.

I don't have much time right now to dig into the details. You cand find the symbols, .dll and .lib + built library here to compare: https://www.dropbox.com/sh/rul49lx01hxjlua/AACi1kLqD10ff0ALo6vX_zaha?dl=0 That was for QL 1.4. I can try to update it to 1.5 but can't promise anything in the coming days. It should not be an issue though.

mtrstudio commented 9 years ago

Hey thanks a lot~ But exactly the same errors occurred even after using the libs you sent to me. Maybe it really has something to do with the compiler itself.

On the other hand, I noticed, my .def file (I changed to quantlib1.4) is different from yours, so I think there are two possibilities here:

  1. the objects files are dependent on the compiler, i.e. msvc2012 and msvc2008 give different object files
  2. the symbol generation function has some kind of bugs

Just some guess, hopefully it will be useful for your development

dpinte commented 9 years ago

Symbols are definitely compiler specific.

! As stated before, you won't get PyQL to run with Python 2.7. if you use msvc2012. It has to be msvc2008 or the MSFT C++ compiler for Python 2.7