Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2222 Discussions

cannot find -lmpi when running mpiifort

fymaterials
Beginner
2,097 Views
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
FC_OPT=/opt/intel/mpi/3.1/bin/mpiifort

# build rules

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

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

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

clean:
rm -f *.mod *.o ${APP}
#*********************************
When I type make debug, it shows error:
ld: skipping incompatible /opt/intel/impi/3.1/lib/libmpi.so 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.

Thanks!
Arthur

0 Kudos
2 Replies
TimP
Honored Contributor III
2,097 Views
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.
0 Kudos
Gergana_S_Intel
Employee
2,097 Views

Hi,

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

FC_OPT=/opt/intel/mpi/3.1/bin/mpiifort

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:

FC_OPT=/opt/intel/mpi/3.1/bin64/mpiifort

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.

Regards,
~Gergana

0 Kudos
Reply