Howto: SuiteSparse under Windows
Patch and build instructions for compiling SuiteSparse under windows using cl.exe and other routine from Visual Studio.
UPDATE 13.04.2013: tested for SuiteSparse 4.0.2 only
SuiteSpare – exists only for *nix-based systems. Officially. But if you want – you can build it and use under windows.
I have to build iSam library under Windows and because it depends on several libraries from SuiteSpare I had to firstly build SuiteSparse. For iSam I need only several libraries from SuiteSparse – AMD, CAMD, COLAMD, CXSparse and, finally, CHOLMOD.
You should take into account that CHOLMOD can be build using fortran-based libraries (using BLAS and LAPACK), using ACML library (Core Math Library) or without them. If it is crucial for you to achieve the best performance – and if you are absolutely sure that you use it – you have to see notes at the end of this article.
Instructions below for building CHOLMOD without any additions as LAPACK, BLAS or METIS (used flags are -DNSUPERNODAL -DNPARTITION).
Instructions step by step:
1. Download and install cygwin.
2. Add to cygwin.bat (c:/cygwin by default) routines for setting up Visual Studio environments:
call “c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat”
call “c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat”
(exact path depend on VisualStudio install path and your target architecture)
3. Download patch for building SuiteSparse under Windows – suitesparse_win and save it into root directory in which located SuiteSparse folder.
4. Run cygwin with cygwin.bat, cd into SuiteSparse directory and type:
For linking your binaries using Visual Studio link utility you have to copy link.exe from VS’s bin folder –
(by default –
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe and
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\link.exe
into cygwin bin folder (by default – c:\cygwin\bin\).
You should name them as link_32.exe and link_64.exe accordingly.
Such trick is necessary due to existance of “link” routine from Cygwin programms set.
5. Now you can build all desired libraries:
There are two types of build : “win32 debug” and “x64 release”.
You can switch between them by changing variables CF, LIB, LINK at makefile SuiteSparse_config.mk (from SuiteSparse_config folder). DO not forget to restart cygwin with appropriate variable set scripts (call to vcvars32.bat or vcvars64.bat)!
Note: Path to the Visual Studio’s libraries are set in that file also. If it is differ from your – linking error as “cannot open file ‘LIBCMT.LIB” – just change it.
You can get appropriate path by typing
this var should been set by vcvars*.bat script during startup of cygwin.
Brief patch description:
– CXSparse – all *.c renamed into *.cpp
– CXSparse – added c-style casts for every memory allocation routine
– all variables CC, CF, ARCHIVE, RUNLIB, LIB are changed to appropriate for Visual Studio
– *.deff files for export symbols were added
– and probably some other minor changes
There is port of SuiteSparse under Windows – https://github.com/PetterS/SuiteSparse.
Under project folder you can find Visual Studio solution files for building CHOLMOD and some others (AMD, CAMD, COLAMD,CCOLAMD).
But_1 – it has modified version of CHOLMOD for use ACML (Core Math Library – AMD library for building SuiteSpare (yeah, yeah it can be used on intel machines).
But_2 – it has settings for x64, for x86 you have to manually edit project settings
But_3 – not all of the libraries have valid export definition files (without them your library will compile without any exported functions).
you can try to build CHOLMOD using LAPACK and BLAS. I spent the whole day to give try it but with no luck. Few tips: use mingw compiler, do not forget that gfortran and all x64 routine in cygwin should be appropriately pointed in SuiteSparse_config.mk.
In case you wish to setup SuiteSparse as Visual Studio project you should keep in mind internal structure of SuiteSparse and different approaches to build it (for example – with and without support of complex numbers – which reflected in recompile the same source with different flags).
how to build LAPACK (for use via CHOLMOD) – http://www.kitware.com/blog/home/post/231
Prebuilt libraries for Microsoft Visual Studio – http://icl.cs.utk.edu/lapack-for-windows/lapack/#libraries