[100%] Linking CXX shared library …/…/lib/libgromacs_mpi.so
/usr/bin/ld: CMakeFiles/libgromacs.dir/listed_forces/bonded.cpp.o: relocation R_X86_64_PC32 against undefined symbol `_ZN12_GLOBAL__N_1L28c_bondedInteractionFunctionsIL18BondedKernelFlavor2EEE’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libgromacs_mpi.so.5.0.0] Error 1
make[1]: *** [src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
make: *** [all] Error 2
Any idea about what could be the cause, and how to proceed ?
I have built 2021.1 and 2020.5 successfully with openmp 4.1.0 and saw some issues randomly with openmp 4.0.0 on the web before. I’d suggest trying 4.1.0 openmp.
The main issue is that one of the libraries you are trying to link against was compiled in such a way that it can not be linked into a shared library. Perhaps you built fftw as static library only? If so build it as shared and that may solve the issue. You can try to work around the issue it by adding -fPIC to the compiler flags (-DCMAKE_CXX_FLAGS="-fPIC").
Thanks for the suggestions. I had already recompiled fftw as shared library, so that should not be a problem. I tried adding -DCMAKE_CXX_FLAGS="-fPIC". Now it goes a bit further than before, but then it returns
[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/gmx.cpp.o
[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
[100%] Linking CXX executable …/…/bin/gmx_mpi
…/…/lib/libgromacs_mpi.a(bonded.cpp.o): In function nrnbIndex(int)': bonded.cpp:(.text+0x16cf6): undefined reference to (anonymous namespace)::c_bondedInteractionFunctions<(BondedKernelFlavor)2>’
collect2: error: ld returned 1 exit status
make[2]: *** [bin/gmx_mpi] Error 1
make[1]: *** [src/programs/CMakeFiles/gmx.dir/all] Error 2
make: *** [all] Error 2