This forum has been archived. All content is frozen. Please use KDE Discuss instead.

umfpack.h not found

Tags: None
(comma "," separated)
dplucenio
Registered Member
Posts
3
Karma
0

umfpack.h not found

Tue Feb 15, 2011 8:59 pm
Hello experts,
This is probably an stupid question from a begginer but:

I intend to use Eigen during my masters, what will involve a lot of sparse matrices solving.
I was experimenting the library and when I tried to add

Code: Select all
#include<Eigen\UmfPackSupport>


I got an error like:


WARNING!
Cannot open include file: 'umfpack.h': No such file or directory u:\libs\eigen-3.0-beta2\unsupported\eigen\umfpacksupport 8 1 LinearAlgebraTesting


I added eigen-3.0-beta2 and eigen-3.0-beta2\unsupported at my additional include directories, looked for umfpack.h in the downloaded files and didn't find it.

What am I doing wrong?

Thank you in advance
dplucenio
Registered Member
Posts
3
Karma
0

Re: umfpack.h not found

Wed Feb 16, 2011 2:49 am
Well it really was a stupid question.
So this part of Eigen code depends on umfpack, a sparse matrix solver library.
Ok, so I've downloaded it, as well as its other dependencies.
But when I try to compile my very simple code, I get another error. That now looks like:

WARNING!
Error 1 error LNK2019: unresolved external symbol _umfpack_di_free_numeric referenced in function "void __cdecl Eigen::umfpack_free_numeric(void * *,double)" (?umfpack_free_numeric@Eigen@@YAXPAPAXN@Z) U:\Projects\TestCodes\LinearAlgebraTesting\LinearAlgebraTesting\Main.obj LinearAlgebraTesting


My code is simply:
Code: Select all
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET

#include <iostream>
#include<Eigen\Sparse>
#include<Eigen\Dense>
#include<Eigen\UmfPackSupport>

using namespace Eigen;

int main()
{
   DynamicSparseMatrix<double,ColMajor> mut(3,3);
   for(int j=0;j<3;++j)
   {   
      mut.insert(j,j)=1;     
   }
   SparseMatrix<double> mat(mut);

   VectorXd b(3);
   VectorXd x(3);
   b << 1,2,3;

   SparseLU<SparseMatrix<double>,UmfPack> lu_of_A(mat);
   lu_of_A.solve(b,&x);

   return 0;
}


Can you help me?
Thanks in advance
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: umfpack.h not found

Wed Feb 16, 2011 4:38 pm
hm.... maybe this is a problem of C vs C++ linkage. Since it is quite difficult for me to test with MSVC could you try to edit the file path_to_eigen/unsupported/Eigen/UmfPackSupport and enclose the #include <umfpack.h> as follow:

Code: Select all
extern "C" {
#include <umfpack.h>
}


thanks
blaubaer
Registered Member
Posts
4
Karma
0

Re: umfpack.h not found

Wed Nov 09, 2011 2:52 pm
Hi,

I get exactly the same linker error, when I try to compile my program.
Eigen Version 3.0.3
Current UmfPack-Version that comes with SuiteSparse.

Did you solve the error? The file:
unsupported/Eigen/UmfPackSupport
already came with:
extern "C" {
#include <umfpack.h>
}

I would appreciate help!
Thank you in advance!
Andre
Registered Member
Posts
90
Karma
1

Re: umfpack.h not found

Wed Nov 09, 2011 7:02 pm
The OP looks as if you were using windows, is that right? Did you link your application against Umfpack? You would have to add it to the additional dependencies in the linker options of your project. For good performance you also require a BLAS library that you need to add there as well.


'And all those exclamation marks, you notice? Five? A sure sign of someone who wears his underpants on his head.' ~Terry Pratchett

'It's funny. All you have to do is say something nobody understands and they'll do practically anything you want them to.' ~J.D. Salinger
blaubaer
Registered Member
Posts
4
Karma
0

Re: umfpack.h not found

Thu Nov 10, 2011 4:05 pm
Hi André,

thanks for the quick response. Since Eigen just consists of header files I was not used to compiling libraries any more ;-)

I followed your hints and this tutorial http://matrixprogramming.com/2008/03/umfpack. First I compiled the whole SparseSuit from cygwin. That was the easiest way to get all dependencies. During the process I also installed blas under cygwin.
Then I followed the Linker errors and after renaming each library from *.a-->*.lib I included
Code: Select all
libmetis.lib
libccolamd.lib
libcamd.lib
libcolamd.lib
liblapack.lib
libblas.lib
libamd.lib
libcholmod.lib
libumfpack.lib

as additional dependencies.

Now I am stuck with the following error:
Code: Select all
1>Verknüpfen...
1>libumfpack.lib(umfpack_gn_tictoc.o) : error LNK2001: Nicht aufgelöstes externes Symbol "_times".
1>libumfpack.lib(umfpack_gn_tictoc.o) : error LNK2001: Nicht aufgelöstes externes Symbol "_sysconf".
1>libcamd.lib(camd_i_2.o) : error LNK2001: Nicht aufgelöstes externes Symbol "___getreent".
1>libblas.lib(xerbla.o) : error LNK2001: Nicht aufgelöstes externes Symbol "___getreent".
1>libblas.lib(cblas_xerbla.o) : error LNK2001: Nicht aufgelöstes externes Symbol "___getreent".
1>libcholmod.lib(cholmod_error.o) : error LNK2001: Nicht aufgelöstes externes Symbol "___getreent".
1>libmetis.lib(util.o) : error LNK2001: Nicht aufgelöstes externes Symbol "___getreent".
1>libmetis.lib(util.o) : error LNK2001: Nicht aufgelöstes externes Symbol "_srand48".
1>libmetis.lib(initpart.o) : error LNK2001: Nicht aufgelöstes externes Symbol "_drand48".
1>libmetis.lib(graph.o) : error LNK2001: Nicht aufgelöstes externes Symbol "_drand48".


I can fix them by including libcygwin.lib but then VS complains that symbols are defined twice
Code: Select all
1>Verknüpfen...
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__ceil ist bereits in libcygwin.lib(d000760.o) definiert.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__printf ist bereits in libcygwin.lib(d001386.o) definiert.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__free ist bereits in libcygwin.lib(d001000.o) definiert.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__malloc ist bereits in libcygwin.lib(d001278.o) definiert.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__srand ist bereits in libcygwin.lib(d001677.o) definiert.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__rand ist bereits in libcygwin.lib(d001483.o) definiert.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __imp__clock ist bereits in libcygwin.lib(d000777.o) definiert.
1>C:\Users\marsl\Programmierung\release/bin/morf_9.dll : fatal error LNK1169: Mindestens ein mehrfach definiertes Symbol gefunden.
1>Das Buildprotokoll wurde unter "file://C:\Users\marsl\Programmierung\release\build\vs9\morf\morf_Release Dll\BuildLog.htm" gespeichert.
1>morf - 8 Fehler, 0 Warnung(en)


So either I have not enough symbols or the wrong ones. Am I doing something completely wrong?

Thanks for suggestions
Andre
Registered Member
Posts
90
Karma
1

Re: umfpack.h not found

Thu Nov 10, 2011 5:10 pm
libcygwin.lib is the runtime library of cygwin, and MSVCRT.lib is the MS runtime. You cannot mix both, as they implement the same functions. If you compile on/for 32bit, you can use MingW to compile SuiteSparse. Otherwise you should try to compile it with the Visual Studio compiler, which is quite some work, because it uses the build system in ugly ways (e.g. the make files define variables which define output names of objects). One way could be to use the msys shell to be able to run makefiles, but modify the makefiles so as to use MSVC toolchain (cl.exe, etc.).


'And all those exclamation marks, you notice? Five? A sure sign of someone who wears his underpants on his head.' ~Terry Pratchett

'It's funny. All you have to do is say something nobody understands and they'll do practically anything you want them to.' ~J.D. Salinger
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: umfpack.h not found

Fri Nov 11, 2011 4:14 am
Another solution would be to use SuperLU instead of UmfPack. SuperLU is much easier to compile with MSVC. I attached a simple CMakeList.txt file that allow you to generate makefiles or build projects for superlu. Just put it in the root of the superlu source folder.
blaubaer
Registered Member
Posts
4
Karma
0

Re: umfpack.h not found

Fri Nov 11, 2011 4:50 pm
Thank you very much for your fast and competent comments. I finally got it to work.

Andre wrote:libcygwin.lib is the runtime library of cygwin, and MSVCRT.lib is the MS runtime. You cannot mix both, as they implement the same functions.
That's what I also figured...

If you compile on/for 32bit, you can use MingW to compile SuiteSparse.
...and that's what I did :-)

I could imagine that other people have the same problem so I try to summarize my steps. I hope I can remember each step because there where quite some detours...

The task was to solve a sparse system of equations
Code: Select all
Ax=b
using Eigen and UmfPack on Windows and Visual Studio 2008.
Code: Select all
SparseMatrix<double,RowMajor> A(N,N);
Eigen::VectorXd b(N),x(N),
SparseLU<SparseMatrix<double>, UmfPack > solver(A);
solver.solve(b,&x);
Important ist the header and the define
Code: Select all
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
#include <unsupported/Eigen/UmfPackSupport>

Efficiently creating the sparse Matrix A needs the A.insertBack(row,col) function. I noticed that the UmfPack solver crashes, when A is RowMajor. So after constructing A as SparseMatrix<double,RowMajor> (for convenience with the rest of my application) I copied it into a ColMajor matrix. (@Gael and André: Is there a more efficient way?) Also, it seems to work only with doubles.
I downloaded SuiteSparse from http://www.cise.ufl.edu/research/sparse/SuiteSparse/ and Metis-4.0.3 from http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/OLD/metis-4.0.3.tar.gz and extracted everything in the same folder. The Metis folder needs to be renamed to metis-4.0.
I installed MinGW and copied gcc.exe to cc.exe. Metis had some dependencies on drand48() and srand48(). I changed them to rand() and srand(). Then I issued
Code: Select all
make library
for suitesparse and
Code: Select all
make
for metis on the MinGW command window. That gave me a lot of static libraries *a which I renamed to *lib and added them as dependencies to my vs project.
Code: Select all
blas_win32_MT.lib lapack_win32_MT.lib libmetis.lib libccolamd.lib libcamd.lib libcolamd.lib libamd.lib libcholmod.lib libumfpack.lib

As you notice I also included the blas and lapack dependencies. You can find the binaries here: http://www.fi.muni.cz/~xsvobod2/misc/lapack/download/lapack-MT-release.zip
Then (after fixing all the bugs in my code) it worked like a charm :-)

I probably forgot steps to mention here. But those guidelines should help you get started.

Cheers and thanks again @André and Gael!
Andre
Registered Member
Posts
90
Karma
1

Re: umfpack.h not found

Fri Nov 11, 2011 5:19 pm
blaubaer wrote:Metis had some dependencies on drand48() and srand48(). I changed them to rand() and srand().


I don't know what impact the lower precision has for metis ordering, but at least drand returns a double between 0 and 1 and rand() returns an int. It might be better to download an implementation for drand e.g. using a mersenne twister or similar algorithms somewhere and link it.


'And all those exclamation marks, you notice? Five? A sure sign of someone who wears his underpants on his head.' ~Terry Pratchett

'It's funny. All you have to do is say something nobody understands and they'll do practically anything you want them to.' ~J.D. Salinger
blaubaer
Registered Member
Posts
4
Karma
0

Re: umfpack.h not found

Mon Nov 14, 2011 10:02 am
Thanks for the advice. I actually changed the line from
Code: Select all
#define RandomInRange(u) ((int)(drand48()*((double)(u))))
to
#define RandomInRange(u) ((int)((double)rand()/(double)INT_MAX)*((double)(u))))

in the file macros.h

But a closer look reveals that
Code: Select all
#ifdef __VC__
#define RandomInRange(u) ((rand()>>3)%(u))
#define RandomInRangeFast(u) ((rand()>>3)%(u))
#else
#define RandomInRange(u) ((int)(drand48()*((double)(u))))
#define RandomInRangeFast(u) ((rand()>>3)%(u))
#endif

so it seems that it is not even necessary to use drand48() on windows. It should work to remove the ifdef and only keep
Code: Select all
#define RandomInRange(u) ((rand()>>3)%(u))
#define RandomInRangeFast(u) ((rand()>>3)%(u))
Andre
Registered Member
Posts
90
Karma
1

Re: umfpack.h not found

Fri Nov 18, 2011 11:03 am
Good to know!

I'll also need to rebuild my CHOLMOD with MSVC for Windows 64 bit soon. If I get around to it, perhaps I'll add some notes here.


'And all those exclamation marks, you notice? Five? A sure sign of someone who wears his underpants on his head.' ~Terry Pratchett

'It's funny. All you have to do is say something nobody understands and they'll do practically anything you want them to.' ~J.D. Salinger


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]