openmpi error during compilation
Asked Answered
F

2

5

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

Footsie answered 9/7, 2013 at 12:42 Comment(1)
Commenting here because this answer showed up in google searches for me. If this error occurs when compiling a fortran main program (mpifort, mpif77 or mpif90) adding the -lmpi_cxx should help.Assert
S
14

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.

Stanwood answered 9/7, 2013 at 13:20 Comment(0)
S
1

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.

Septic answered 10/7, 2013 at 1:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.