Issue 1432: PARPACK build fails when MPI libs are not in PATH

Reported by Roland Wirth, May 14, 2014

Steps to reproduce the problem:
1. Make sure that the MPI libs are not in the library path
2. ./configure --enable-mpi
3. make

Expected result:
Make should succeed.

Actual result:
libtool fails to link Error is

/bin/sh ../libtool  --tag=F77   --mode=link mpif77  -g -O2 
-no-undefined -version-info 2:0  -o -rpath 
/usr/local/lib64  ../SRC/ ../UTIL/ 
../PARPACK/UTIL/MPI/ -lblas -llapack -lmpi 
libtool: link: gfortran -shared  -fPIC  -Wl,--whole-archive 
../SRC/.libs/libarpacksrc.a ../UTIL/.libs/libarpackutil.a 
../PARPACK/UTIL/MPI/.libs/libparpackutilmpi.a -Wl,--no-whole-archive 
 -lblas -llapack -lmpi  -O2   -Wl,-soname -Wl, -o 
n/ld: cannot find -lmpi

Reason seems to be that libtool knows nothing about the additional 
linker flags the compiler wrapper supplies so that, when it calls 
gfortran to link the .so, the linker is lacking the MPI library 
paths. The problem can be solved by setting the LIBRARY_PATH 
environment variable to include the appropriate paths in the make 
invocation, but this seems tedious to me. Another solution would be 
to have libtool call mpif77 as the linker instead of gfortran but I 
have no idea how to do that.

The third solution is to use an Autoconf macro for the MPI 
configuration that I recently stumbled upon: this macro calls the 
MPI wrappers to get the compiler and linker flags explicitly so that 
MPI can be used like an ordinary library. The original macro can be 
found at

I've attached a modified version that I use for my own projects. It 
should be more portable and Fortran-compatible. However, I am not 
very experienced in writing Autoconf macros so there might be 
something I have missed.

Created: 4 years 12 days ago by Roland Wirth

Status: New