1
votes

I'm trying to run the following simple example from Xcode4:

#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <iostream>
namespace mpi = boost::mpi;

int main(int argc, char* argv[])
{
  mpi::environment env(argc, argv);
  mpi::communicator world;
  std::cout << "I am process " << world.rank() << " of " << world.size()
  << "." << std::endl;
  return 0;
}

I've added libboost_mpi and libboost_serialization to Xcode, and compiling using the default LLVM returns :

/usr/local/include/boost/mpi/communicator.hpp:1329:9: error: call to implicitly-deleted copy constructor of 'boost::mpi::communicator' : comm(comm), source(source), tag(tag), ia(comm), value(value) ^ ~~~~

However, I can compile and run using

mpic++ -I/usr/local/include main.cpp -L/usr/local/lib -lboost_mpi -lboost_serialization

Although mpic++ seems to be calling through to LLVM:

$ mpic++

i686-apple-darwin11-llvm-g++-4.2: no input files

Anyways, I tried adding mpic++ as a compiler option in Xcode 4. I can run

$ sudo opensnoop -n Xcode | grep mpicc.xcspec

and see that the spec file is being loaded by Xcode, but I don't see any MPICC option. My spec file is fairly simple:

/**
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/local/bin/mpicc”;
    PrecompStyle = pch;
}

and it's stored in

/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/LLVM GCC 4.2.xcplugin/Contents/Resources/mpicc.xcspec

1
did you compile Boost MPI? you need to compile it separately from the rest of the boost librariespyCthon
Yes. I've compiled and installed BoostMPI, and I have openmpi for the actual mpi implementationHamy
maybe change the output of sudo opensnoop -n Xcode | grep mpicc.xcspec to that of mpic++pyCthon
or try linking whatever version of mpi your using separately and compile with clang or g++pyCthon
use the output from mpic++ --showme:link -v and mpic++ --showme:compile -vpyCthon

1 Answers

0
votes

So this works:

link binary with:

libmpi_cxx.dylib
libmpi.dylib
libboost_mpi.dylib
libboost_serialization.dylib

Change compiler (under build options) to LLVM GCC 4.2 (hinted at by running mpic++ directly, which reports that it's using llvm gcc 4.2 internally)

Under targets, build phases, compile sources, add the compiler option "-lm" to report that you need to link with libm. Credit to @pyCthon for pointing out mpic++ --showme:link which revealed the final library that was allowing it to build successfully from the command line