MPI on xCode

Geeky Stuff

I am currently working on a small MPI project, and I had one hell of a time getting MPI up and running, specifically the MPICC (compiler) to work in xCode.

So here it is if you were wondering how to get it to work:

Put the following into a file called MPICC.pbcompspec

/**
Xcode Compiler Specification for MPICC
*/
{   Type = Compiler;
Identifier = com.apple.compilers.mpicc;
BasedOn = com.apple.compilers.gcc.4_2;
Name = “MPICC”;
Version = “Default”;
Description = “MPI GNU C/C++ Compiler 4.0″;
ExecPath = “/usr/bin/mpicc”;      // This gets converted to the g++ variant automatically
PrecompStyle = pch;
}

Note: ExecPath should be set to your mpicc path, find this by typing which mpicc in terminal. BasedOn should be set to whatever the system GCC is (4.2 for snow leopard).

Save this file to the following directory: /Developer/Library/Xcode/Specifications/, if the directory does not exist, create it, restart xCode.

Finally in your project, open the build targets and select the one you want to build with MPICC, get info on it, and add a custom rule for c source, MPICC should be in the list somewhere, if it is not then you messed up somewhere above.

Setting a custom C xCode target rule

Setting a custom C xCode target rule

The file: mpicc.pbcompspec

Sources:

http://lists.apple.com/archives/xcode-users/2008/Apr/msg00104.html

http://www.open-mpi.org/community/lists/devel/2007/02/1313.php

2 Comments

  1. Danny  •  Jan 2, 2010 @9:07 am

    I tried this using C++. I created a separate MPICXX.pbcompspec specification for the C++ MPI compiler mpicxx, and created a second Build Rule for C++ files. However, I ran into linker errors.

    I fixed it by selecting MPICXX for both C and C++ source files.

  2. joegaudet  •  Jan 4, 2010 @2:27 pm

    Thanks for the comment Danny, I am sure someone will find it helpful. I never was able to get MPI running on my actual macs, so I ended up just using the Linux clusters at school.

    .joe

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>