Elmer/Ice can't pass 'make'

Extension of Elmer in computational glaciology
Post Reply
yushuoliu
Posts: 3
Joined: 21 Jan 2021, 09:49
Antispam: Yes

Elmer/Ice can't pass 'make'

Post by yushuoliu »

dear all:
I'm a new user of the Elmer/Ice, in recent days I am trying to install Elmer/Ice, but lots of error occurred ! I was download the source code by "git clone" command, and follow the step from "http://elmerfem.org/elmerice/wiki/doku. ... ationcmake" and "readme" file in elmerice directory. when I type "make", the error occurred:

"[ 51%] Linking Fortran shared library libelmersolver.so
/usr/bin/ld: /usr/local/lib/libmmg.a(inout_3d.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [fem/src/CMakeFiles/elmersolver.dir/build.make:1487:fem/src/libelmersolver.so] 错误 1
make[1]: *** [CMakeFiles/Makefile2:17748:fem/src/CMakeFiles/elmersolver.dir/all] 错误 2
make: *** [Makefile:163:all] 错误 2"

I have found the solution on internet, should recompile with "-fPIC", but I don't know where should add this optional, or is there has other solution to fix this problem?
My computer: CPU: AMD 2700X; Main board: ASUS X370; OS: Ubuntu 20.04
I'm preparing my Ph.D thesis, so I need numerical simulation of glacier in the Qilian mountain, west China.
So I need solve this problem!
Thanks for anyone can provide help!
Best
regards!
fgillet
Posts: 46
Joined: 30 Sep 2010, 16:58

Re: Elmer/Ice can't pass 'make'

Post by fgillet »

Hello;
mmg has too be compiled with the -fPIC flags;

You have to set
CMAKE_CXX_FLAGS=-fPIC
CMAKE_C_FLAGS=-fPIC
when using cmake to configure the compilation of mmg.

In general you will have to set this flag is most external librairies that you want to link with Elmer

best regards
Fabien
yushuoliu
Posts: 3
Joined: 21 Jan 2021, 09:49
Antispam: Yes

Re: Elmer/Ice can't pass 'make'

Post by yushuoliu »

Hi Fabien
Thanks for your replay.
I'll trying to solve this problem with your suggest.
If has any result/question, I'll write here for others as reference.
Best Wishes!
yushuoliu
Posts: 3
Joined: 21 Jan 2021, 09:49
Antispam: Yes

Re: Elmer/Ice can't pass 'make'

Post by yushuoliu »

fgillet wrote: 21 Jan 2021, 12:04 Hello;
mmg has too be compiled with the -fPIC flags;

You have to set
CMAKE_CXX_FLAGS=-fPIC
CMAKE_C_FLAGS=-fPIC
when using cmake to configure the compilation of mmg.

In general you will have to set this flag is most external librairies that you want to link with Elmer

best regards
Fabien

Hello Fabien and others:
I have tried many times to solve the "-fPIC" problem, I found that if added the "-fPIC" in the "cmakelists.txt" file, it doesn't work.
But I used another solution fixed this problem.
Add "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true" option behind "cmake", e.g:
cmake -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true .. -DWITH_OpenMP:BOOLEAN=TRUE -DWITH_MPI:BOOLEAN=TRUE -DWITH_ElmerIce:BOOLEAN=TRUE -DWITH_Mumps:BOOL=TRUE

But unfortunately, a new error occurred :

[ 65%] Building Fortran object elmerice/Solvers/CMakeFiles/ElmerIceSolvers.dir/CalvingRemeshMMG.F90.o
/home/ys/elmerfem/elmerice/Solvers/CalvingRemeshMMG.F90:432:45:

432 | CALL MMG3D_mmg3dls(mmgMesh,mmgSol,ierr)
| 1
Error: Type mismatch in argument ‘met’ at (1); passed INTEGER(4) to INTEGER(8)
make[2]: *** [elmerice/Solvers/CMakeFiles/ElmerIceSolvers.dir/build.make:1103:elmerice/Solvers/CMakeFiles/ElmerIceSolvers.dir/CalvingRemeshMMG.F90.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:16756:elmerice/Solvers/CMakeFiles/ElmerIceSolvers.dir/all] 错误 2
make: *** [Makefile:163:all] 错误 2

I have no idea about this, and no information/solution on internet.
Welcome any help!
Best Regards!

Yushuo Liu
Post Reply