Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build openmpi with homebrew and gcc-4.9?

By default brew install openmpi uses clang to create its wrapper.

I need to specify gcc-4.9(Homebrew installed) for the wrapper.

I have tried

$export CC=gcc-4.9
$brew install openmpi

$brew install --cc=gcc-4.9 openmpi

$brew install --with-gcc49 openmpi

$brew install -CC=gcc-4.9 -CXX=g++-4.9 -FC=gfortran -F77=gfortran openmpi

$brew install openmpi --cc=gcc-4.9 

$brew install openmpi --CC=gcc-4.9 --CXX=g++-4.9 --FC=gfortran --F77=gfortran

Finally, I've modified the openmpi formula adding:

 args = %W[
  CC=gcc-4.9 
  CXX=g++-4.9 
  FC=gfortran 
  F77=gfortran

I still get

$mpicc --showme
clang -I/usr/local/Cellar/open-mpi/1.8.4/include -L/usr/local/opt/libevent/lib -L/usr/local/Cellar/open-mpi/1.8.4/lib -lmpi
like image 681
ilciavo Avatar asked Jan 13 '15 19:01

ilciavo


1 Answers

Finally it was solved as follows:

1) Add environment variables for homebrew (you can also add these lines to your ~\.bashrc):

export HOMEBREW_CC=gcc-4.9
export HOMEBREW_CXX=g++-4.9

2) Rebuild and reinstall openmpi and its dependencies from source

brew reinstall openmpi --build-from-source

3) In the end you will get a message like:

==> Reinstalling open-mpi
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.
==> Downloading http://www.open-mpi.org/software/ompi/v1.8/downloads/openmpi-1.8.
Already downloaded: /Library/Caches/Homebrew/open-mpi-1.8.4.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/open-mpi/1.8.4 --disable-silent-rules 
==> make all
==> make check
==> make install
Warning: open-mpi dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.
🍺  /usr/local/Cellar/open-mpi/1.8.4: 785 files, 23M, built in 41.2 minutes

$mpicc --showme 
gcc-4.9 -I/usr/local/Cellar/open-mpi/1.8.4/include -L/usr/local/opt/libevent/lib -L/usr/local/Cellar/open-mpi/1.8.4/lib -lmpi

On my MacBook I had some conflicts with XCode 6.2, which were solved following this instructions

However, I decided to stay with the clang version to avoid issues with gfortran.

like image 175
ilciavo Avatar answered Sep 23 '22 05:09

ilciavo