Registered Member
|
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
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 |
Registered Member
|
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:
Can you help me? Thanks in advance |
Moderator
|
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:
thanks |
Registered Member
|
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! |
Registered Member
|
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 |
Registered Member
|
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
as additional dependencies. Now I am stuck with the following error:
I can fix them by including libcygwin.lib but then VS complains that symbols are defined twice
So either I have not enough symbols or the wrong ones. Am I doing something completely wrong? Thanks for suggestions |
Registered Member
|
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 |
Moderator
|
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.
|
Registered Member
|
Thank you very much for your fast and competent comments. I finally got it to work.
That's what I also figured... ...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
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
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! |
Registered Member
|
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 |
Registered Member
|
Thanks for the advice. I actually changed the line from
in the file macros.h But a closer look reveals that
so it seems that it is not even necessary to use drand48() on windows. It should work to remove the ifdef and only keep
|
Registered Member
|
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 |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]