Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQL building issues #86

Open
mtrstudio opened this issue Apr 27, 2015 · 7 comments
Open

PyQL building issues #86

mtrstudio opened this issue Apr 27, 2015 · 7 comments

Comments

@mtrstudio
Copy link

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 -D__WIN32
_ -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
ow_4date___get
@@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
@@YAHPEAU__pyx_obj_8q
uantlib_8cashflow_SimpleCashFlow@@NPEAU__pyx_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

@mtrstudio mtrstudio changed the title Building issues PyQL building issues Apr 27, 2015
@dpinte
Copy link
Member

dpinte commented Apr 27, 2015

@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
Copy link

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
Copy link
Member

dpinte commented Apr 27, 2015

@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
Copy link
Author

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
Copy link
Member

dpinte commented Apr 29, 2015

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
Copy link
Author

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
Copy link
Member

dpinte commented Apr 30, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants