Topic: Error linking PETSc

Hi, Borek

We compiled the solver PETSc and generated some static library files. The following error occurred when installing OOFEM.

How to make OOFEM run PETSc static library compilation?

We are looking forward to your help. Thank you very much my friends

****************************************************************************
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(cdf.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(or.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(and.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(bipartite.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(degree.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(dasub.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(bitmask.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(dmlocalsnes.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(vi.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(dmlocalts.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(dmplexts.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(simple.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /public/home/WL/petsc-3.14.0/arch-linux-cxx-debug/lib/libpetsc.a(andor.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/liboofem.dir/build.make:1241: liboofem.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:1121: CMakeFiles/liboofem.dir/all] Error 2
make: *** [Makefile:147: all] Error 2
**********************************************************************************

Re: Error linking PETSc

Have you tried what compiler tells you, i.e., to recompile with -fPIC?

Re: Error linking PETSc

Thank you very much for your reply.

However, we need static compiled PETSc.

If we use - FPIC to compile PETSc, we will lose the content of modifying PETSc.

Re: Error linking PETSc

Try to set USE_SHARED_LIB  to OFF. This parameter is by default set to ON.