Failed to compile using mpich and gcc

2.6k Views Asked by At

I have compiled mpich 3.2 with gcc 4.8.3 on centos. Everything seems to be fine. Then I wrote a simple test program,

#include "mpi.h"
int main(int argc,char **argv)
{}

and use the mpic++ to compile. Then errors return,

/home/setups/mpich-3.2/build/lib/libmpi.so: undefined reference to _intel_fast_memcpy' /home/setups/mpich-3.2/build/lib/libmpi.so: undefined reference to__intel_sse2_strncmp' /home/setups/mpich-3.2/build/lib/libmpi.so: undefined reference to _intel_fast_memset' /home/setups/mpich-3.2/build/lib/libmpi.so: undefined reference to__intel_sse2_strlen'

What exactly goes wrong? I'm so confused that the error seems to be related with intel compilers, but I use gcc to compile mpich by the command,

./configure --prefix=/home/setups/mpich-3.2/build/ CC=gcc CXX=gcc F77=gfortran FC=gfortran

I have added /home/setups/mpich-3.2/build/bin to PATH and /home/setups/mpich-3.2/build/lib to LD_LIBRARY_PATH

mpicc -v shows:

mpicc for MPICH version 3.2
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/setups/gcc-4.8.3/build/libexec/gcc/x86_64-unknown-linux-gnu/4.8.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/home/setups/gcc-4.8.3/build --with-gmp=/home/setups/gmp-6.1.2/build --with-mpfr=/home/setups/mpfr-3.1.5/build --with-mpc=/home/setups/mpc-1.0.3/build --disable-multilib
Thread model: posix
gcc version 4.8.3 (GCC)
2

There are 2 best solutions below

0
Reenactor Rob On

You might find your solution at the open-mpi.org site and their faq for building MPI. For example, item 17.

A common mistake when building Open MPI with the Intel compiler suite is to accidentally specify the Intel C compiler as the C++ compiler. Specifically, recent versions of the Intel compiler renamed the C++ compiler "icpc" (it used to be "icc", the same as the C compiler). Users accustomed to the old name tend to specify "icc" as the C++ compiler, which will then cause a failure late in the Open MPI build process because a C++ code will be compiled with the C compiler. Bad Things then happen. The solution is to be sure to specify that the C++ compiler is "icpc", not "icc". For example:

https://www.open-mpi.org/faq/?category=building

0
Gilles Gouaillardet On

/home/setups/mpich-3.2/build/lib/libmpi.so: undefined reference to _intel_fast_memcpy'

This strongly suggests an Intel compiler was used to build mpich.

That can happen is gcc/g++/gfortran is not in your PATH or if your environment points to the Intel compiler (e.g. CC=icc or CXX=icpc or FC=ifort).