PDA

View Full Version : linking mpi errors


neo_in_matrix
21st May 2008, 09:42 AM
I am getting MANY linking errors when linking to libmpi.

Here is my simple test program:

#include <iostream>
#include <mpi.h>

using namespace std;

int main(int argc, char** argv)
{
int rc = MPI_Init(&argc, &argv);
if(rc != MPI_SUCCESS)
{
cout << "MPI_Init failed" << endl;
return -1;
}

int num, rank;

MPI_Comm_size(MPI_COMM_WORLD, &num);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
cout << num << " task, " << rank << " is " << rank << endl;

MPI_Finalize();
return 0;
}


===============
and this is the makefile:

INCLUDE=-I /usr/include/openmpi/1.2.4-gcc
LIB=-L /usr/lib/openmpi/1.2.4-gcc
LIBS=-lmpi
FLAGS=
TGT=mpitest.exe
SRCs=mpitest.cxx

$(TGT): $(SRCs)
g++ $(INCLUDE) $(LIB) -o $(TGT) $(SRCs)


====================
g++ -I /usr/include/openmpi/1.2.4-gcc -L /usr/lib/openmpi/1.2.4-gcc -o mpitest.exe mpitest.cxx -lmpi
In file included from /usr/include/openmpi/1.2.4-gcc/openmpi/ompi/mpi/cxx/mpicxx.h:246,
from /usr/include/openmpi/1.2.4-gcc/mpi.h:1783,
from mpitest.cxx:2:
/usr/include/openmpi/1.2.4-gcc/openmpi/ompi/mpi/cxx/request_inln.h: In static member function ‘static MPI::Grequest MPI::Grequest::Start(int (*)(void*, MPI::Status&), int (*)(void*), int (*)(void*, bool), void*)’:
/usr/include/openmpi/1.2.4-gcc/openmpi/ompi/mpi/cxx/request_inln.h:347: warning: declaration ‘struct MPI::Grequest_intercept_t’ does not declare anything
/tmp/ccjMrWFi.o: In function `MPI::Intracomm::Intracomm()':
mpitest.cxx:(.text._ZN3MPI9IntracommC2Ev[MPI::Intracomm::Intracomm()]+0xd): undefined reference to `MPI::Comm::Comm()'
/tmp/ccjMrWFi.o: In function `MPI::Intracomm::Intracomm(ompi_communicator_t*)':
mpitest.cxx:(.text._ZN3MPI9IntracommC1EP19ompi_com municator_t[MPI::Intracomm::Intracomm(ompi_communicator_t*)]+0xf): undefined reference to `MPI::Comm::Comm()'
/tmp/ccjMrWFi.o: In function `MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool)':
mpitest.cxx:(.text._ZN3MPI2Op4InitEPFvPKvPviRKNS_8 DatatypeEEb[MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool)]+0x17): undefined reference to `ompi_mpi_cxx_op_intercept'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI3WinE[vtable for MPI::Win]+0x14): undefined reference to `MPI::Win::Set_errhandler(MPI::Errhandler const&)'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI3WinE[vtable for MPI::Win]+0x24): undefined reference to `MPI::Win::Free()'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI9IntercommE[vtable for MPI::Intercomm]+0xd4): undefined reference to `MPI::Comm::Set_errhandler(MPI::Errhandler const&)'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI9GraphcommE[vtable for MPI::Graphcomm]+0xd4): undefined reference to `MPI::Comm::Set_errhandler(MPI::Errhandler const&)'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI8CartcommE[vtable for MPI::Cartcomm]+0xd4): undefined reference to `MPI::Comm::Set_errhandler(MPI::Errhandler const&)'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI9IntracommE[vtable for MPI::Intracomm]+0xd4): undefined reference to `MPI::Comm::Set_errhandler(MPI::Errhandler const&)'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI4CommE[vtable for MPI::Comm]+0xd4): undefined reference to `MPI::Comm::Set_errhandler(MPI::Errhandler const&)'
/tmp/ccjMrWFi.o:(.rodata._ZTVN3MPI8DatatypeE[vtable for MPI::Datatype]+0x3c): undefined reference to `MPI::Datatype::Free()'
collect2: ld returned 1 exit status
make: *** [mpitest.exe] Error 1

Freshly installed Fedora 9 and did yum install openmpi*.

MarkS
21st May 2008, 11:14 AM
Why are you compiling with gcc? Try mpicc -o $(TGT) $(SRCs) Always use the wrappers! Also post mpicc -showme.