Compiling and Using TAUCS under Microsoft Visual Studio


TAUCS is a Library of Sparse Linear Solvers developed by Prof Sivan Toledo with Doron Chen and Vladimir Rotkin:

The goal of this chapter is to consider how to compile TAUCS under Microsoft Visual Studio. The plan is as follows. First we compile TAUCS with nmake from the command line. Then a simple example will be compiled from both command line and GUI.

TAUCS depends on METIS and BLAS. I will use the TAUCS version that already contains all the auxiliary libraries:

Be careful unpacking the archive, as it assumes that you have already made the directory taucs by yourself. Please note that you need either the libraries from ATLAS (libatlas.lib, libcblas.lib, libf77blas.lib, liblapack.lib, libmetis.lib, vcf2c.lib) or LAPACK with the reference BLAS (blas_win32.lib, lapack_win32.lib, vcf2c.lib) but not all of them together. ATLAS libraries are recommended. The performance of TAUCS with ATLAS is considerably faster.

Provided you use you own versions of METIS and BLAS please modify command accordingly.

I acknowledge the help of Alejandro and dhw. You will find links to their messages below in Discussion.

By default TAUCS is compiled with -MT. If you need to have it with -MD, follow the steps described in

Compiling and Using TAUCS under Microsoft Visual Studio with -MD

Yet, it make sense to read this document first. The paper about -MD assumes that you already understand the stuff described here.

Compiling TAUCS

TAUCS is aware of Visual Studio and it is relatively easy to compile it. Some problem though is that this must be done from the command line.

1) Preparing cmd

The use of Visual Studio from the command line requires that some environment variables must be correctly defined. A good introduction to environment variables is in Wikipedia

This goal can be achieved by running a shortcut in Programs | Visual C++ 2005 Express Edition | Visual Studio Tools | Visual Studio 2005 Command prompt. If it is unavailable, please search vsvars32.bat (it could be names also as vsvars32.txt). In my installation it is in

C:\Programme\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat

It is good to check that all the variable are defined correctly and then one can execute it as

$ "C:\Programme\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"

where one needs quotes because there are spaces in the path. You have to modify the command above accordingly.

In any case when everything is done correctly the next two commands

$ nmake

$ cl

should return the versions of tools. Below it is assumed that this has been done and you are in the directory where you have unpacked the archive (use cd to change the directory).

$ dir /b

2) Running configure

$ configure.bat

configure.bat is a small script that first builds configurator\configurator.exe and then runs it. The program creates makefiles to build TAUCS. If everything was successful you should find configurator\configurator.exe and then also makefile in build/win32.

According to Alejandro there are some problems along this way with Visual Studio 2008. I have not installed it yet and could not troubleshoot it. If you have problems please report. The script configure.bat is relatively simple and it is possible to run command manually and thus to find what is wrong.

3) Running nmake

$ nmake

nmake compiles the library libtaucs.lib in lib/win32 and some exe in bin/win32. I usually check that everything went okay with

$ bin\win32\direct -mesh2d 400 -log stdout -snmf

Using TAUCS from the command line

By using command line it is simpler to show what is necessary to define to successfully compile a code using TAUCS. Copy file test_taucs.cpp to the root of the TAUCS distribution. First we compile it and then link with the libraries.

1) Compiling

We need to tell compiler where it will find the headers. In TAUCS the main header is in src and in turn it requires two other headers that are in build\win32.

$ cl -c -Isrc -Ibuild\win32 -EHsc test_taucs.cpp

Note that we only tell the compiler where to search the headers. What headers are necessary is specified in the code. The -c tells that we need to compile the code only and -EHsc is necessary to treat exceptions correctly (I do not know why it is not by default).

2) Linking

Now we have to link test_taucs.obj with the libraries. Here we need to specify not only where to find the libraries but also with which libraries to link, as the code does not contain such information.

$ cl test_taucs.obj libtaucs.lib libmetis.lib liblapack.lib libf77blas.lib libcblas.lib libatlas.lib vcf2c.lib -link -LIBPATH:lib\win32 -LIBPATH:external\lib\win32

After the object file one specifies the library needed, and with LIBPATH the path to the libraries.

The command above has used ATLAS as BLAS. It is also possible to compile the code with the reference (not optimized) BLAS

$ cl test_taucs.obj libtaucs.lib libmetis.lib lapack_win32.lib blas_win32.lib vcf2c.lib -link -LIBPATH:lib\win32 -LIBPATH:external\lib\win32

but it will be much slower.

3) Running the code

If everything went correctly then

$ test_taucs.exe

should show you first some debugging information from TAUCS and then the answer (0 2 0 4).

Using TAUCS from GUI

Now it is also possible to compile and run the code from GUI by specifying the information above through the dialog boxes.

1) Note that TAUCS was compiled with -MT. Specify it also in C++ –> Code generation –> Use run-time library.

2) Specify the path to the TAUCS headers in ADDITIONAL INCLUDE DIRECTORIES.

3) Specify the library to link with in Link –> Input: Object/library modules.

4) Specify the path to the libraries in ADDITIONAL PATH LIBRARY.

Now it should work.

Working with TAUCS by using low-level functions

The function to call TAUCS in test_taucs.cpp is taucs_linsolve – in the manual it is called as a unified linear solver. Unfortunately it is an experimental version and it does not work correctly if one first needs to factor a matrix and then run the back substitution several times. The code test_taucs2.cpp demonstrates it. It could be possible to find the error in the taucs_linsolve code but I would suggest an easier solution – to use low-level TAUCS functions. The code test_taucs_lowlevel.cpp shows how to do it.

Related Paper

Compiling and Using TAUCS under Microsoft Visual Studio with -MD


Problem running TAUCS in Microsoft Visual C++ 6.0
problem about study TAUCS (a new learner)
help:taucs_linsolve failed when I tempt to use the factorization!
Compiling and Using TAUCS under Microsoft Visual Studio
[help] taucs on linux
New to TAUCS, need to compile with Multi-threaded Debug DLL (/MDd) in VS .NET 2003
Sundry questions on composing and solving equations with TAUCS
Has Taucs provided the function of sparse matrix multiply?
Can TAUCS handle negative values in the diagonal of a matrix?
matlab vs taucs
Does Taucs have a fortran interface?
taucs with multithreaded debug dll option


12 responses to “Compiling and Using TAUCS under Microsoft Visual Studio”

Comments are now closed
  1. oliver says:

    hi, i am having a problem following these instructions. when I run nmake after configure, I get a linking error for dgemm_ and dgemm. these should exist in the blas libraries that come packaged with the full TAUCS distribution? Do I need to change any paths/environment variables from the defaults?


  2. This presumably happens when it compiles examples. Have you recieved libtaucs.lib in lib/win32? Have you used It contains the libraries indeed.

    You could check it by going to step Using TAUCS from the command line.

  3. oliver says:

    Hm, so I get this when it is trying to build the tests (i.e. taucs_blash_underscore_test), which is the first line called after running configure and then nmake.

    I do not have libtaucs.lib, this is what I am trying to compile, but I am not sure why it is first compiling the tests.

    I am using taucs_full, and have all the other lib files under /external/lib/win32. Thanks,

  4. Sorry, I have misunderstood your problem. TAUCS first compiles test programs to take a decision whether BLAS names have underscore or not. This is what happens by me right now

    cl -c /nologo /O2 /W3 /D “WIN32” /MT -DMACHTYPE_i386 -I src\\ -I build\\win32\\ -I external\\src\\ progs\\taucs_blas_underscore_test.c /Foobj\\win32\\taucs_blas_underscore_test.obj taucs_blas_underscore_test.c
    progs\\taucs_blas_underscore_test.c(33) : warning C4996: ‘fopen’: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\stdio.h(234): Siehe Deklaration von ‘fopen’
    cl /nologo /MT /F64000000 /Feobj\\win32\\taucs_blas_underscore_test.exe obj\\win32\\taucs_blas_underscore_test.obj external\\lib\\win32\\liblapack.lib external\\lib\\win32\\libf77blas.lib external\\lib\\win32\\libcblas.lib external\\lib\\win32\\libatlas.lib external\\lib\\win32\\libmetis.lib external\\lib\\win32\\vcf2c.lib
    obj\\win32\\taucs_blas_underscore_test.exe build\win32\taucs_config_tests.h

    Linking with dgemm_ succedded

    As you see the test was successful. I guess that by you not. Could you please post the lines that you see by you?

  5. oliver says:

    yes, that’s correct. here is the beginning of the output of my ‘nmake’:

    cl -c /nologo /O2 /W3 /D “WIN32” /MT -DMACHTYPE_ -I src\\ -I build\\ win32\\ -I external\\src\\ progs\\taucs_blas_underscore_test.c /Foobj\\win32 \\taucs_blas_underscore_test.obj taucs_blas_underscore_test.c progs\\taucs_blas_underscore_test.c(33) : warning C4996: ‘fopen’: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\stdio.h(23
    7) : see declaration of ‘fopen’

    cl /nologo /MT /F64000000 /Feobj\\win32\\taucs_blas_underscore_test.exe obj\\win32\\taucs_blas_underscore_test.obj external\\lib\\win32\\liblapack.lib external\\lib\\win32\\libf77blas.lib external\\lib\\win32\\libcblas.lib external\\lib\\win32\\libatlas.lib external\\lib\\win32\\libmetis.lib external\\lib\\win32\\vcf2c.libtaucs_blas_underscore_test.obj : error LNK2019: unresolved external symbol dgemm
    _ referenced in function main

    obj\\win32\\taucs_blas_underscore_test.exe : fatal error LNK1120: 1 unresolved externals
    obj\\win32\\taucs_blas_underscore_test.exe build\win32\taucs_config_tests.h ‘obj\\win32\\taucs_blas_underscore_test.exe’ is not recognized as an internal or external command, operable program or batch file.


  6. My only guess is that you may need some flag in MS VS9, presumably they have changed something in default behavior. I would advice you to copy the obj file and libraries in one directory and try to link by hand. You could check what names are in the obj file and the libraries for example with nm in cygwin, see how to use nm for example here

    So just make sure that you have dgemm_ in the object file and in the library (I guess in libf77blas.lib), then try to link from the command line. If this does not work ask why at some MS group, for example

    I am not going soon to switch to VS9. Sorry. Could it be that they by default assume a .c file as C++?

    You could also post your question at

    It well might be that someone has already tried TAUCS with VS9. Put VS9 in the subject – this is clearly the reason.

  7. jbgao says:

    A better way to compile Taucs with MS VC++ 2010 Express:

    The first time when I installed the library, I followed the following steps (I am using MS VC++ on windows)
    >nmake (library created)
    >testscript (it worked well except I failed at the first program of cilk.)

    After that, when I tried to build my own programs (projects) and I got link errors (missing many references from libtaucs.lib). I spent quite a bit time to research on the internet and found that many have experienced the similar problem. It is only today after carefully tracing scripts I noted that libtaucs.lib is no longer the original one produced from nmake. The original one was deleted in running testscript.bat which calls to configure to produce a new makefile. In this new makefile, there is a block code of the following

    $(DIRLIB)libtaucs$(LIBEXT): $(libtaucs_content) $(STDDEPS)
    – $(RM) $(DIRLIB)libtaucs$(LIBEXT)
    $(AR) $(AOUTFLG)$(DIRLIB)libtaucs$(LIBEXT) $(libtaucs_content)
    $(RANLIB) $(DIRLIB)libtaucs$(LIBEXT)

    where $RM removes the libtaucs.lib that we need. Instead only relevant object files to the last test are packaged into the new libtaucs.lib which is not the one for other programming.

    The best way is to make a copy of libtaucs.lib before you run testscript.bat (OR SIMPLY DON’T TRY TESTSCRIPT AT ALL), or to make a change to the program configure so that a relevant library name is used for each test example in testscript (I reported this to the author).


  8. jbgao says:


    Can you change test_taucs_lowlevel.cpp for a non symmetrical coefficient matrix. In that case, not sure which function to replace taucs_ccs_permute_symmetrically which causes the same error as test_taucs2.cpp when A is non-symmetric.


  9. TAUCS includes the LU factorization but it is rather slow. Here I would you recommend you MUMPS or UMFPACK. You will find some code to call all of them inlcuding TAUCS LU

  10. vahid says:

    Thanks for the useful information on your website. I compiled and used the TAUCS for the test_example.cpp and it works fine. But I noticed it sometimes does not work for other matrices.
    For example if you only change an[1] from 0.5 to any number greater than 0.9 (say 1.0) solver gives “Generic Error”. (I checked this case with my calculator and it gives me answer).
    I appreciate if someone can help me.

  11. vahid says:

    Problem solved! My matrix was not positive definite.

  12. lh cheng says:

    how can use taucs with cilk in visual studio 2008 on windows? and why I’m try the testscritp and these are some fail in the testscript.log ?