Page 1 of 1

Linking LAPACK to MFEM

PostPosted: Wed Nov 23, 2016 10:28 pm
by kvoronin
Hello everyone,

I am trying to build and run MFEM software using latest netlib lapack.
1) Without using lapack I am able to build mfem and run examples
2) I build MFEM with make parallel -j MFEM_USE_METIS_5=YES METIS_DIR=@MFEM_DIR@/../metis-5.1.0 MFEM_USE_LAPACK=YES MFEM_USE_SUITESPARSE=YES and it ran ok, I got the lib.
3) I try to compile a MFEM example by running
mpicxx -O3 -I.. -I../../hypre-2.11.1/src/hypre/include -I/home/kvoronin/Documents/suitesparse/SuiteSparse/include ex1p.cpp -o ex1p -L.. -lmfem -L../../metis-5.1.0 -lmetis -L../../hypre-2.11.1/src/hypre/lib -lHYPRE -L"/home/kvoronin/Documents/lapack/lapack-3.6.1" -llapack -lrt -L/home/kvoronin/Documents/suitesparse/SuiteSparse/KLU/lib -L/home/kvoronin/Documents/suitesparse/SuiteSparse/lib -lklu -lbtf -lumfpack -lcholmod -lcolamd -lamd -lcamd -lccolamd -lsuitesparseconfig -lrt -L../../metis-5.1.0 -lmetis -L"/home/kvoronin/Documents/lapack/lapack-3.6.1" -llapack
and got an error:
usr/bin/ld: /home/kvoronin/Documents/lapack/lapack-3.6.1/liblapack.a(xerbla.o): undefined reference to symbol '_gfortran_string_len_trim@@GFORTRAN_1.0'
//usr/lib/x86_64-linux-gnu/libgfortran.so.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
makefile:39: recipe for target 'ex1p' failed

What can be the reason? It seems like there is something wrong with lgfortran or fortran flags, but I could not work it out.
Adding lgfortran to the build lines above did not help.
Should I do something with my lapack build or do something with the linker options for the example?

I would appreciate any help!

Re: Linking LAPACK to MFEM

PostPosted: Thu Nov 24, 2016 3:23 am
by Julien Langou
It looks to me as if you are missing the gfortran library.
Looking at the error message, you probably compiled LAPACK using gfortran.
Then when you link your code, you are using `mpicxx`.
At link time, you are missing the FORTRAN compiler libraries.
Maybe try to simply add something like a -lgfortran at the end of your link command.

Also it is likely that you will miss the BLAS. So something like
-llapack -lrefblas -lgfortran
Might be better.

Looking better I see a `//usr/lib/x86_64-linux-gnu/libgfortran.so.3` so actually you might have gfortran in your path but maybe not the good version.

Can you try adding -lgfortran to your link command line?
Can you try adding -lrefblas -lgfortran to your link command line?

Re: Linking LAPACK to MFEM

PostPosted: Sun Nov 27, 2016 6:03 pm
by kompom
Julien Langou wrote:It looks to me as if you are missing the gfortran library.
Looking at the error message, you probably compiled LAPACK using gfortran.
Then when you link your code, you are using `mpicxx`.
At link time, you are missing the FORTRAN compiler libraries.
Maybe try to simply add something like a -lgfortran at the end of your link command.

Also it is likely that you will miss the BLAS. So something like
-llapack -lrefblas -lgfortran
Might be better.

Looking better I see a `//usr/lib/x86_64-linux-gnu/libgfortran.so.3` so actually you might have gfortran in your path but maybe not the good version.

Can you try adding -lgfortran to your link command line?
Can you try adding -lrefblas -lgfortran to your link command line?


I do not quite understand what you mean.