How to build SuiteSparse under Windows using Visual Studio

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:
     patch -p1<../SuiteSparse_win.diff

UPDATE 13.04.2013:
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:
     make isam_libs

There are two types of build : “win32 debug” and “x64 release”.
You can switch between them by changing variables CFLIB, LINK at makefile (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

Notes 1:
There is port of SuiteSparse under Windows –
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).

Notes 2:
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

Notes 3:
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) –
Prebuilt libraries for Microsoft Visual Studio –


1 pings

    • Philipp on January 14, 2014 at 1:08 am
    • Reply


    Thanks a lot for the instructions, they really saved me a few days of work!!
    One note: for individual libraries, I got the linking error
    LINK : fatal error LNK1146: no argument specified with option ‘/OUT:’
    The error refers to the windows-archiver lib.exe, which has this syntax. Is it a problem with the patch (that it did not modify the link-lnes in makefiles), or is something missing on my system?

    Anyway, for my purposes it was not critical as I could do the linking “by hand”. But for others it may be of use…


    1. Hello and thank you for point out this issue.
      Could you please specify which version of SuiteSparse do you use? I will check it.

      Probably, in new version of SuiteSparse were introduced some changes breaking current version of patch.

  1. […] « How to build SuiteSparse under Windows using Visual Studio […]

Leave a Reply

Your email address will not be published.