On MacOS 10.5.2 standard installation with Open MPI 1.2.3 the
following hello world program in normal C compiles just fine and runs
correctly.
But if I rename the file to mpihello.cpp and I get many undefined
symbols at link time!
This error cropped up while I was working with a much more complex mpi
program, but it occurs even with this simplest of programs. The error
also occurs if I change the hello world program to use the C++
function forms, such as MPI::Init() and MPI::COMM_WORLD.Get_rank().
Probably I'm just being embarrassingly stupid.
Thanks in advance.
mpihello.cpp:
#include <stdio.h>
#include <mpi.h>
int main ( int argc, char *argv[] )
{
int rank, size;
MPI_Init (&argc, &argv);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
MPI_Comm_size (MPI_COMM_WORLD, &size);
printf( "Hello world from process %d of %d\n", rank, size );
MPI_Finalize();
return 0;
}
compiler output:
mpiCC -o mpihello mpihello.cpp
Undefined symbols:
"MPI::Datatype::Free()", referenced from:
vtable for MPI::Datatypein ccQqJJlF.o
"MPI::Win::Set_errhandler(MPI::Errhandler const&)", referenced from:
vtable for MPI::Winin ccQqJJlF.o
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in ccQqJJlF.o
"MPI::InitializeIntercepts()", referenced from:
MPI::Real_init() in ccQqJJlF.o
"operator new[](unsigned long)", referenced from:
MPI::Datatype::Get_contents(int, int, int, int*, int*,
MPI::Datatype*) constin ccQqJJlF.o
MPI::Comm::Alltoallw(void const*, int const*, int const*,
MPI::Datatype const*, void*, int const*, int const*, MPI::Datatype
const*) constin ccQqJJlF.o
MPI::Intracomm::Create_cart(int, int const*, bool const*, bool)
constin ccQqJJlF.o
MPI::Intracomm::convert_info_to_mpi_info(int, MPI::Info
const*)in ccQqJJlF.o
MPI::Cartcomm::Get_topo(int, int*, bool*, int*) constin
ccQqJJlF.o
MPI::Cartcomm::Sub(bool const*)in ccQqJJlF.o
MPI::Cartcomm::Map(int, int const*, bool const*) constin
ccQqJJlF.o
"___cxa_pure_virtual", referenced from:
vtable for MPI::Commin ccQqJJlF.o
"operator new(unsigned long)", referenced from:
MPI::Intracomm::Clone() constin ccQqJJlF.o
MPI::Cartcomm::Clone() constin ccQqJJlF.o
MPI::Graphcomm::Clone() constin ccQqJJlF.o
MPI::Intercomm::Clone() constin ccQqJJlF.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccQqJJlF.o
"operator delete[](void*)", referenced from:
MPI::Datatype::Get_contents(int, int, int, int*, int*,
MPI::Datatype*) constin ccQqJJlF.o
MPI::Comm::Alltoallw(void const*, int const*, int const*,
MPI::Datatype const*, void*, int const*, int const*, MPI::Datatype
const*) constin ccQqJJlF.o
MPI::Intracomm::Create_cart(int, int const*, bool const*, bool)
constin ccQqJJlF.o
MPI::Intracomm::Spawn_multiple(int, char const**, char
const***, int const*, MPI::Info const*, int)in ccQqJJlF.o
MPI::Intracomm::Spawn_multiple(int, char const**, char
const***, int const*, MPI::Info const*, int, int*)in ccQqJJlF.o
MPI::Cartcomm::Get_topo(int, int*, bool*, int*) constin
ccQqJJlF.o
MPI::Cartcomm::Sub(bool const*)in ccQqJJlF.o
MPI::Cartcomm::Map(int, int const*, bool const*) constin
ccQqJJlF.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccQqJJlF.o
"_ompi_mpi_cxx_op_intercept", referenced from:
_ompi_mpi_cxx_op_intercept$non_lazy_ptr in ccQqJJlF.o
"MPI::Comm::Comm()", referenced from:
MPI::Intracomm::Intracomm()in ccQqJJlF.o
MPI::Intracomm::Intracomm(ompi_communicator_t*)in ccQqJJlF.o
"vtable for __cxxabiv1::__si_class_type_info", referenced from:
typeinfo for MPI::Prequestin ccQqJJlF.o
typeinfo for MPI::Grequestin ccQqJJlF.o
typeinfo for MPI::Commin ccQqJJlF.o
typeinfo for MPI::Intracommin ccQqJJlF.o
typeinfo for MPI::Cartcommin ccQqJJlF.o
typeinfo for MPI::Graphcommin ccQqJJlF.o
typeinfo for MPI::Intercommin ccQqJJlF.o
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for MPI::Datatypein ccQqJJlF.o
typeinfo for MPI::Opin ccQqJJlF.o
typeinfo for MPI::Statusin ccQqJJlF.o
typeinfo for MPI::Requestin ccQqJJlF.o
typeinfo for MPI::Groupin ccQqJJlF.o
typeinfo for MPI::Comm_Nullin ccQqJJlF.o
typeinfo for MPI::Winin ccQqJJlF.o
typeinfo for MPI::Errhandlerin ccQqJJlF.o
typeinfo for MPI::Infoin ccQqJJlF.o
"MPI::Comm::Set_errhandler(MPI::Errhandler const&)", referenced
from:
vtable for MPI::Commin ccQqJJlF.o
vtable for MPI::Intracommin ccQqJJlF.o
vtable for MPI::Cartcommin ccQqJJlF.o
vtable for MPI::Graphcommin ccQqJJlF.o
vtable for MPI::Intercommin ccQqJJlF.o
"MPI::Win::Free()", referenced from:
vtable for MPI::Winin ccQqJJlF.o
"operator delete(void*)", referenced from:
MPI::Datatype::~Datatype()in ccQqJJlF.o
MPI::Datatype::~Datatype()in ccQqJJlF.o
MPI::Status::~Status()in ccQqJJlF.o
MPI::Status::~Status()in ccQqJJlF.o
MPI::Request::~Request()in ccQqJJlF.o
MPI::Request::~Request()in ccQqJJlF.o
MPI::Request::~Request()in ccQqJJlF.o
MPI::Prequest::~Prequest()in ccQqJJlF.o
MPI::Prequest::~Prequest()in ccQqJJlF.o
MPI::Grequest::~Grequest()in ccQqJJlF.o
MPI::Grequest::~Grequest()in ccQqJJlF.o
MPI::Group::~Group()in ccQqJJlF.o
MPI::Group::~Group()in ccQqJJlF.o
MPI::Comm_Null::~Comm_Null()in ccQqJJlF.o
MPI::Comm_Null::~Comm_Null()in ccQqJJlF.o
MPI::Comm_Null::~Comm_Null()in ccQqJJlF.o
MPI::Win::~Win() in ccQqJJlF.o
MPI::Win::~Win() in ccQqJJlF.o
MPI::Errhandler::~Errhandler()in ccQqJJlF.o
MPI::Errhandler::~Errhandler()in ccQqJJlF.o
MPI::Comm::~Comm()in ccQqJJlF.o
MPI::Comm::~Comm()in ccQqJJlF.o
MPI::Comm::~Comm()in ccQqJJlF.o
MPI::Intracomm::~Intracomm()in ccQqJJlF.o
MPI::Intracomm::~Intracomm()in ccQqJJlF.o
MPI::Intracomm::~Intracomm()in ccQqJJlF.o
MPI::Info::~Info()in ccQqJJlF.o
MPI::Info::~Info()in ccQqJJlF.o
MPI::Intercomm::~Intercomm()in ccQqJJlF.o
MPI::Intercomm::~Intercomm()in ccQqJJlF.o
MPI::Intracomm::Clone() constin ccQqJJlF.o
MPI::Cartcomm::~Cartcomm()in ccQqJJlF.o
MPI::Cartcomm::~Cartcomm()in ccQqJJlF.o
MPI::Graphcomm::~Graphcomm()in ccQqJJlF.o
MPI::Graphcomm::~Graphcomm()in ccQqJJlF.o
MPI::Cartcomm::Clone() constin ccQqJJlF.o
MPI::Graphcomm::Clone() constin ccQqJJlF.o
MPI::Op::~Op() in ccQqJJlF.o
MPI::Op::~Op() in ccQqJJlF.o
"MPI::FinalizeIntercepts()", referenced from:
MPI::Finalize() in ccQqJJlF.o
"MPI::COMM_WORLD", referenced from:
__ZN3MPI10COMM_WORLDE$non_lazy_ptr in ccQqJJlF.o
ld: symbol(s) not found
collect2: ld returned 1 exit status