I have previously tried compiling an earlier version of gromacs without MPI on WSL as well and it installed successfully. Searching for ‘undefined reference to MPI’ errors suggested that I add the -DMPI_C_COMPILER=mpicc to cmake, but after adding that I still get the same errors. I have the latest versions of gcc, cmake, and mpich.
tar -xf .. gromacs..
cd gromacs-...
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=(name of your serial c compiler, e.g. gcc) \
-DCMAKE_CXX_COMPILER=(name of c++ serial compiler, e.g. g++) \
-DGMX_MPI=on -DCMAKE_PREFIX_PATH=/path/to/required/mpilibrarydir1:\
/path/to/required/mpilibrarydir2:
make
make check
make install
Configure script will then automatically detect the compiler wrappers.
The CMAKE_PREFIX_PATH is to make sure that configure script finds all the libraries. You can skip that if all of the required library paths are given in the LD_LIBRARY_PATH environment variable or if the libraries are detected by the system through ldconfig utility.
Here’s a method which I used to install GROMACS:
Step 1: Install MPI implementation
wget link-to-mpi-installation-archive.gz
tar-xf your-mpi-implementation
mkdir build1
cd build1
../configure --prefix=/opt/mpi
make install
Step 2: make mpi executable files and libraries are detectable globally. (This step assumes Debian like OS)
sudo ln -s /opt/mpi/bin/m* /usr/local/bin
sudo nano /etc/ld.so.conf.d/customlibs.conf
(add a line - /opt/mpi/lib save and close)
sudo ldconfig -v
(check the output to make sure all required libs are detected)
Step 3: GROMACS installation like in the previous post without the CMAKE_PREFIX_PATH option to cmake.
If you installed mpich using apt (or some other package manager) then you need to make sure that you have all the libraries installed as well
sudo apt install build-essential libmpich12 libmpich-dev ...(and any other dependencies or required packages)