Problems installing OpenCoarrays under WSL2 on Windows 11

I am trying to install the OpenCoarrays feature for gfortran under WSL2. This turned out to be much more problematic than I hoped it would be. Here is what I did:

  • I tried building from source, but that turned out not to be necessary.
  • So I installed the libcoarrays-mpich-dev package.
  • Compiling and linking via “caf” however gives a lot of missing libraries:

caf -o timing timing.f90
f951: Warning: Nonexistent include directory ‘/usr/lib/x86_64-linux-gnu/openmpi/lib/…/…/fortran/gfortran-mod-15/openmpi’ [-Wmissing-include-dirs]
/usr/bin/ld: cannot find -lmpi_usempif08: No such file or directory
/usr/bin/ld: cannot find -lmpi_usempi_ignore_tkr: No such file or directory
/usr/bin/ld: cannot find -lmpi_mpifh: No such file or directory
/usr/bin/ld: cannot find -lopen-rte: No such file or directory
/usr/bin/ld: cannot find -lopen-pal: No such file or directory
/usr/bin/ld: cannot find -lhwloc: No such file or directory
/usr/bin/ld: cannot find -levent_core: No such file or directory
/usr/bin/ld: cannot find -levent_pthreads: No such file or directory
collect2: error: ld returned 1 exit status
Error: comand:
/usr/bin/mpif90.openmpi -I/usr/lib/x86_64-linux-gnu/fortran/ -fcoarray=lib -o timing timing.f90 /usr/lib/x86_64-linux-gnu/open-coarrays/openmpi/lib/libcaf_openmpi.a

Apparently, I am missing a set of packages, but I have no idea which ones.

Any suggestions?

1 Like

Looking at the error messages you might try:

sudo apt install openmpi-bin openmpi-common libopenmpi-dev
sudo apt install libhwloc-dev libevent-dev
sudo apt-get install libpthread-stubs0-dev

If I recall the Ubuntu packages (that WSL pulls from by default) are outdated and broken (could be wrong). I recommend using the install script in the OpenCoarrays repo.

Thanks, it took a while to build OpenCoarrays, or rather MPICH, but it does work now.

(I tried building it before under Cygwin, but I got a build error due to the redefinition of some C type)