Question

I'm using lion and xcode 4.2. I installed openmpi using macports. It all installed successfully.

I cannot, however find a guide to tell me how/which libraries to include to compile an example (see below)

#include <mpi.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    int numprocs;
    int myid;
    MPI_Status stat; 

    /* all MPI programs start with MPI_Init */
    MPI_Init(&argc,&argv);     

    /* Comm_size tells us how many processes there are  */
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs); 

    /* Comm_rank finds the rank of the process */
    MPI_Comm_rank(MPI_COMM_WORLD,&myid); 

    /* Print out a message */
    printf("Hello world, from process %d of %d\n", myid, numprocs);  

    /* MPI Programs end with MPI Finalize; this is a weak synchronization point */
    MPI_Finalize(); 

    return 0; 
} 

Xcode reports that mpi.h is missing.

Was it helpful?

Solution

Open-mpi has a walkthrough to do exactly this. Here you go.

OTHER TIPS

This is really easy. You can either follow the instructions in OpenMPI website or you could do the following (which will help you link any program with any other library).

In the Navigator (left panel) select the project. In the Build settings search for Library Search Paths and put the path where the MPI libraries are (/usr/local/lib)

Then look for User Header Search Paths and put the path where the MPI headers are (/usr/local/include)

Finally, in the Build Phases look for Link Binary with Libraries click on the plus sign (+), click on Add Other, press Cmd+Shift+G and put the path where the libraries libmpi.1.dylib, libmpi_cxx.1.dylib are (/usr/local/lib) add both, build and run and it should work like a charm.

A little bit late but probably this helps someone else.

You want to do 2 things:

1) Grab

libmpi.1.dylib

libmpi_cxx.1.dylib

and copy them in the project folder of your app

2) add to the HEADER_SEARCH_PATHS the location of your mph.h file (probably /usr/local/include)

Also check if your $PATH has the path where you installed OpenMPI; failing in doing so will result in an error at compile time.

Good luck!

In addition to Dhaivat's link, there are some Open-MPI tutorials here and here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top