yig / PySPQR

Python wrapper for the sparse QR decomposition in SuiteSparseQR.
Creative Commons Zero v1.0 Universal
34 stars 27 forks source link

Building on Windows #6

Closed akaszynski closed 3 years ago

akaszynski commented 7 years ago

Hello,

I've been trying to build this on Windows and I'm running into problems. I'm getting unresolved external symbols when installing despite having built SuiteSparse and making the libraries and header files available to Python.

Here's the error I'm getting:

(C:\Anaconda2) C:\Users\VM-Windows\Desktop\sparseqr-1.0.0>python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to sparseqr.egg-info\requires.txt
writing sparseqr.egg-info\PKG-INFO
writing top-level names to sparseqr.egg-info\top_level.txt
writing dependency_links to sparseqr.egg-info\dependency_links.txt
reading manifest file 'sparseqr.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'sparseqr.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
generating cffi module 'build\\temp.win-amd64-2.7\\Release\\sparseqr._sparseqr.c'
already up-to-date
building 'sparseqr._sparseqr' extension
C:\Users\VM-Windows\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD
/W3 /GS- /DNDEBUG -IC:\Anaconda2\Library\include\suitesparse -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tcbuild\temp.win-amd64
-2.7\Release\sparseqr._sparseqr.c /Fobuild\temp.win-amd64-2.7\Release\build\temp.win-amd64-2.7\Release\sparseqr._sparseqr.obj

sparseqr._sparseqr.c
C:\Users\VM-Windows\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INC
REMENTAL:NO /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 libspqr.lib /
EXPORT:init_sparseqr build\temp.win-amd64-2.7\Release\build\temp.win-amd64-2.7\Release\sparseqr._sparseqr.obj /OUT:build\lib.
win-amd64-2.7\sparseqr\_sparseqr.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\temp.win-amd64-2.7\Release\_sparseqr.lib
/MANIFESTFILE:build\temp.win-amd64-2.7\Release\build\temp.win-amd64-2.7\Release\_sparseqr.pyd.manifest
sparseqr._sparseqr.obj : warning LNK4197: export 'init_sparseqr' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\build\temp.win-amd64-2.7\Release\_sparseqr.lib and object build\temp.win
-amd64-2.7\Release\build\temp.win-amd64-2.7\Release\_sparseqr.exp
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol SuiteSparseQR_C_QR referenced in function _cffi_d_SuiteSpa
rseQR_C_QR
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol SuiteSparseQR_C_backslash referenced in function _cffi_d_S
uiteSparseQR_C_backslash
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol SuiteSparseQR_C_backslash_sparse referenced in function _c
ffi_d_SuiteSparseQR_C_backslash_sparse
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_allocate_dense referenced in function _cffi_d_ch
olmod_l_allocate_dense
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_allocate_triplet referenced in function _cffi_d_
cholmod_l_allocate_triplet
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_check_triplet referenced in function _cffi_d_cho
lmod_l_check_triplet
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_finish referenced in function _cffi_d_cholmod_l_
finish
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_free referenced in function _cffi_d_cholmod_l_fr
ee
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_free_dense referenced in function _cffi_d_cholmo
d_l_free_dense
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_free_sparse referenced in function _cffi_d_cholm
od_l_free_sparse
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_free_triplet referenced in function _cffi_d_chol
mod_l_free_triplet
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_print_triplet referenced in function _cffi_d_cho
lmod_l_print_triplet
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_sparse_to_triplet referenced in function _cffi_d
_cholmod_l_sparse_to_triplet
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_start referenced in function _cffi_d_cholmod_l_s
tart
sparseqr._sparseqr.obj : error LNK2019: unresolved external symbol cholmod_l_triplet_to_sparse referenced in function _cffi_d
_cholmod_l_triplet_to_sparse
build\lib.win-amd64-2.7\sparseqr\_sparseqr.pyd : fatal error LNK1120: 15 unresolved externals
error: command 'C:\\Users\\VM-Windows\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd6
4\\link.exe' failed with exit status 1120

I noticed that these are all declarations within ffibuilder.cdef(). Could this be a simple bug when porting to Windows?

yig commented 7 years ago

It looks like a linker error when compiling the shim that connects the Python to the C library (using the python package cffi). Unfortunately, neither I not the other maintainer of this project run Windows, so I can't really help debug this. You could try updating your cffi. You could also check if the compiler you are using (I see "Visual C++ for Python\9.0\") is the same one that SuiteSparse itself was compiled with. Sometimes that is a problem.

harusametime commented 7 years ago

Hi,

I successfully installed PySPQR on Windows 10. In my case, the problem is resolved by changing the following sentence in sparseqr_gen.py:

from

libraries=['spqr'])

to

libraries=['amd','btf','camd','ccolamd','cholmod','colamd','cxsparse'
'klu','lapack','ldl','lumfpack','metis','suitesparseconfig','spqr','libblas'])

Those are the names of the libraries that are generated by installing SuiteSparse.

yig commented 7 years ago

@akaszynski Does the suggestion by @harusametime work for you?

akaszynski commented 7 years ago

It looks promising. Let me build it and let you know.

yig commented 3 years ago

Marking as closed. Please re-open if this is still an issue.