cannot find -lmpi when running mpiifort

cannot find -lmpi when running mpiifort

I am using intel MPI 3.1 and I wrote a fortran program using mpiifort.
The following is makefile

# application name
APP = parallel_femsim

# list of source files
SRC = ran2.f90 globals.f90 model.f90 scattering_factors.f90 fem1.f90 parallel_femsim.f90

# list of object files
OBJ = ran2.o globals.o model.o scattering_factors.o fem1.o parallel_femsim.o

# define libraries needed by the linker
#LIBS = -lmkl

# compiler options for debugging
FC_DEBUG = mpif90 -g -debug -implicitnone

# compiler options for optmized running
#FC_OPT = ifort -O3 -xO -ipo -no-prec-div -static
#FC_OPT = mpif90 -O3 -ipo -static
#FC_OPT = mpif90 -o3

# build rules

.SUFFIXES: .f90 .o
${FC_DEBUG} -c $<

debug: ${OBJ}
${FC_DEBUG} -o ${APP} ${OBJ} ${LIBS}

opt: ${SRC}
${FC_OPT} -o ${APP} ${SRC}

rm -f *.mod *.o ${APP}
When I type make debug, it shows error:
ld: skipping incompatible /opt/intel/impi/3.1/lib/ when searching for -lmpi
ld: skipping incompatible /opt/intel/impi/3.1/lib/libmpi.a when searching for -lmpi
ld: cannot find -lmpi
make: *** [debug] Error 1

I am confused what is the use of -lmpi and how to solve this problem.


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If you have 64-bit objects, this message about incompatibility with 32-bit libraries is to be expected. It should be less confusing if you would follow the expected procedure of setting the environment variables by the mpivars script (the one in /bin64/ if building for 64-bit mode) and make a clean rebuild.
Note that mpif90 invokes gfortran, while mpiifort invokes ifort, and the corresponding objects would normally be incompatible, even if built for consistent 32- or 64-bit mode.


To follow-up on Tim's advice, most likely the issues stems from this line in your Makefile:


This will, in fact, link the 32-bit version of the Intel MPI Library (or -lmpi). To instead use the 64-bit versions, you need to do:


In general, instead of manually defining your lib path, we recommend you source the appropriate mpivars scripts from the bin/ directory (for 32-bit executables) and bin64/ directory (for 64-bit executables) if you're running on an Intel 64 machine.

Hope this helps. Let us know if you have other questions.


Leave a Comment

Please sign in to add a comment. Not a member? Join today