openmpi error during compilation

15,007

Solution 1

It looks like you're not linking with the correct library. When you compile code for MPI (whether it's Open MPI, MPICH, or any other implementation), you need to use the MPI compiler wrappers to compile rather than gcc directly.

Instead of saying gcc myprog.c, you need to say mpicc myprog.c. Or, as is the case for this application, change g++ myprog.c to mpic++ myprog.c.

Under the hood, MPI will call GCC (or whatever other compiler you tell it to use) to do the actual compilation, but it will also add all of the appropriate libraries, compiler flags, and whatever else you need.

Solution 2

User posted the same question here:

http://www.open-mpi.org/community/lists/users/2013/07/22296.php

The solution posted on the mailing list was: use mpiCC (or mpic++), not mpicc.

Share:
15,007
didymos
Author by

didymos

Updated on June 28, 2022

Comments

  • didymos
    didymos almost 2 years

    I am trying to locally compile software which uses openmpi (1.6.3), but I got this error:

    restraint_camshift2.o:(.toc+0x98): undefined reference to `ompi_mpi_cxx_op_intercept'

    restraint_camshift2.o: In function `Intracomm':

    /home/users/didymos/openmpi-1.6.3/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'

    /home/users/didymos/openmpi-1.6.3/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to MPI::Comm::Comm()' restraint_camshift2.o: In functionIntracomm':

    /home/users/didymos/openmpi-1.6.3/include/openmpi/ompi/mpi/cxx/intracomm_inln.h:23: undefined reference to MPI::Comm::Comm()' restraint_camshift2.o: In functionIntracomm':

    /home/users/didymos/openmpi-1.6.3/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'

    /home/users/didymos/openmpi-1.6.3/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'

    restraint_camshift2.o:/home/users/didymos/openmpi-1.6.3/include/openmpi/ompi/mpi/cxx/intracomm.h:25: more undefined references to `MPI::Comm::Comm()' follow restraint_camshift2.o:(.data.rel.ro._ZTVN3MPI3WinE[_ZTVN3MPI3WinE]+0x48):

    undefined reference to `MPI::Win::Free()' restraint_camshift2.o:(.data.rel.ro._ZTVN3MPI8DatatypeE[_ZTVN3MPI8DatatypeE]+0x78):

    undefined reference to `MPI::Datatype::Free()' collect2: error: ld

    returned 1 exit status make[3]: * [mdrun] Error 1 make[3]: Leaving

    directory `/home/users/didymos/src/gromacs-4.5.5/src/kernel' make[2]: * [all-recursive] Error 1

    make[2]: Leaving directory `/home/users/didymos/src/gromacs-4.5.5/src'

    make[1]: * [all] Error 2

    make[1]: Leaving directory `/home/users/didymos/src/gromacs-4.5.5/src'

    make: * [all-recursive] Error 1

    I am using gcc 4.7.3 Any ideas or suggestions? Thanks! Best,

    tomek