views:

57

answers:

3

when i am running my mpi program written in c language.It is giving error "undefined reference to `MPI_recv' " , what should i do to solve this error.

A: 

You need to link to the MPI library that provides the MPI_recv() function. For example, with gcc, you would add an option like -lmpi to your compile line.

caf
-1: it's a matter of case not linkage -- as @Roman advises.
High Performance Mark
@High Performance Mark: In that case (boom-boom), there should be another warning about "implicit function definition". Considering the numerous other missing capital letters in the question ("When", "I", "MPI", "C"), it's possible that the error message wasn't transcribed perfectly.
caf
A: 

MPI implementations usually provide a compilation utility scripts that basically sets up the correct compilation & linking environment, libraries and calls gcc (e.g.) with the correct command line.

Try this:

mpicc my_prog.c

Hope this helps.

A.

Adrien
+2  A: 

It is MPI_Recv, not MPI_recv.

Roman Cheplyaka
+1: as you say, case is the issue.
High Performance Mark