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

Comments are closed.