如何使用自制软件和gcc-4.9构建openmpi?

时间:2015-01-13 19:58:29

标签: gcc clang homebrew openmpi

默认情况下brew install openmpi使用clang创建其包装器。

我需要为包装器指定gcc-4.9(已安装Homebrew)。

我试过了

$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

最后,我修改了openmpi公式添加:

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

我还是

$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

1 个答案:

答案 0 :(得分:8)

最后它解决了如下:

1)为自制软件添加环境变量(您也可以将这些行添加到~\.bashrc):

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

2)从源

重建并重新安装openmpi及其依赖项
brew reinstall openmpi --build-from-source

3)最后你会得到一条消息:

==> 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

在我的MacBook上,我与XCode 6.2发生了一些冲突,这些冲突在this instructions之后解决了

但是,我决定继续使用clang版本以避免gfortran出现问题。