Configuring Mac OS X to Build Trilinos Using Macports
|OS X Version:||Instructions have been tested on OS X 10.11|
One of the largest obstacles to building Trilinos is properly configuring and installing the different third party libraries (TPLs) needed by many of its packages. On a Linux platform, package management tools such as
yum for redhat and its derivatives or
apt-get for Debian and its derivatives ease the burden of installing the third party software. Most unix platforms provide similar package managers, such as FreeBSD's ports system. Additionaly, many Linux/unix distributions come prepackaged with most of the necessary developer tools and third party libraries needed for building and working with Trilinos.
Mac OS X, on the other hand, does not provide a native package manager (though third party tools such as Homebrew and MacPorts help fill the gap). In fact, factory builds of Mac OS X do not even provide compilers so that users can build the necessary TPLs. Developers/users who want to build Trilinos on Mac OS X must first install the Apple provided Developer Tools (which includes a compiler suite) and any required third party software before building Trilinos.
In this guide, steps for preparing a Mac OS X machine to build Trilinos are presented. The MacPorts package manager will be employed for third party software management. A local MacPorts port index will be set up that provides the proper versions/patches for each of the installed TPLs. The guide finishes with some Mac OS X specific configuration suggestions for building Trilinos.
Homebrew seems to have won mindshare over Macports in recent years (see, for example, this article in slant). However, MacPorts offers a clear advantage over Homebrew by allowing the user to install multiple versions of the same compiler, multiple MPI vendors/versions, and to build third party software against the compiler/mpi combination of their choice. For help building Trilinos using Homebrew installed TPLs, see the instructions on the Nalu project website. For those interested in even more configurability, spack may be the ultimate choice for managing TPLs needed for scientific software.
A Note for Sandia Developers
For developers with access to Sandia National Labs' cee lan, SEMs provides compilers and third party libraries that can be used for building Trilinos. Search for "SEMs" in the internal TechWeb.
Install the Apple Developer Tools
Xcode is the application provided by Apple that contains the necessary suite of tools to develop on OS X (including compilers, libraries, etc.). Download the latest version of Xcode using the Mac App Store. After Xcode is installed, run
xcode-select --install in a terminal (
/Applications/Utilities/Terminal.app). Click the
Install button to install the required command line developer tools.
See the MacPorts guide for more detailed instructions.
Set Up a Local Port Index
A local port index is a local set of instructions for building specific third party software using MacPorts. The set of ports needed for building Trilinos are housed at the authors' ports github repository. The included ports came originally from the MacPorts project. In some cases, a port is just a copy of the most recent port without modification. In others, the port is modified to build the version/variant needed by Trilinos. Unmodified Ports are included so that Portfiles for all of the necessary TPLs for Trilinos live in one place.
devel/boost1.58.0: At the time of this writing, boost provided by MacPorts is at version 1.59.0. A bug in that version prevents using the variants
-no_single, as needed by Trilinos.
devel/yaml-cpp0.5.3: The default version of yaml-cpp in the Macports repository is 0.5.1. This port is still not fully automated. It should get the right tarball from github. But, it does not. Consequently, a zipfile from github must be downloaded and placed in
/opt/local/var/macports/distfiles/yaml-cpp. The downloaded version must be the 0.5.3 release version. Newer versions of
c++11and this port has not yet been updated to reflect that change. The checksums in the
Portfilewill almost assuredly need to be modified to reflect the checksums of the actual downloaded file.
math/SuiteSparse4.2.1: Port not modified.
math/metis1.51.0: Port modified to build with
math/parmetis4.0.3: Port not modified, but uses the modified metis port.
math/superlu4.3: MacPorts provides v5.2.1 but Trilinos is only guaranteed to work with v4.3
math/superlu_dist4.3: MacPorts provides a newer version, this version is consistent with superlu 4.3
science/hdf51.10: Fixes for fortran and parallel variants
science/pnetcdf1.7.0: Build of parallel-netcdf, needed for
science/hdf5-181.8.17: Fixes for fortran and parallel variants to be consistent with netcdf. Other options as required by seacas are turned on by default.
science/netcdf4.4.1: Modified to properly build parallel netcdf for
NC_MAX_DIMSmodified for use in seacas.
+longindexvariant turned on by default to be consistent with
In the following, assume the
ports directory was cloned to
/Users/user/Documents/ports and MacPorts is installed in
opt/local. Adjust paths as necessary for your system.
Clone the Local Ports
cd /Users/user/Documents git clone https://www.github.com/tjfulle/ports
Add the directory to MacPorts
sources.conf configuration file
Add the line
before the default
/opt/local/etc/macports/sources.conf. See Installing Local Ports.
Now add the ports to the port index:
cd /Users/user/Documents/ports /opt/local/bin/portindex
Installing the Local Ports
The modified ports should appear first in the port index and will take precedence over the ports packaged with MacPorts. Ports can be installed by the standard
port install <port name> [port variants]
The following script will install the
gcc compiler (version 6.3), the default version of
openmpi (version 1.10.1 at the time of this writing), and each of the above listed ports. As you can see, several of the ports are built with and without mpi. After installation, to switch back and forth between versions use
port activate <port name> @<port version>.
#!/bin/sh set -x port=/opt/local/bin/port # Set the compiler vendor, major, and minor versions. # If clang, the compiler name needs to be modified compiler_vendor=gcc compiler_major_version=6 compiler_minor_version=3 if [ $compiler_vendor == clang ]; then compiler=$compiler_vendor$compiler_major_version$compiler_minor_version else compiler=$compiler_vendor$compiler_major_version fi # Compiler dependent ports are: superlu, boost, metis, hdf5, netcdf, SuiteSparse $port install $compiler || exit $port install superlu +$compiler || exit $port install boost +$compiler configure.compiler=macports-$compiler_vendor-$compiler_major_version || exit $port install yaml-cpp +$compiler || exit $port install metis +$compiler || exit $port install hdf5-18 +$compiler +fortran || exit $port install netcdf +$compiler || exit $port install hdf5 +$compiler +fortran || exit $port install SuiteSparse +$compiler || exit # OPENMPI Ports installed are: openmpi, boost, parmetis, scotch, hdf5, pnetcdf, netcdf mpi=openmpi $port install $mpi-$compiler +threads || exit $port install boost +$compiler +$mpi configure.compiler=macports-$compiler_vendor-$compiler_major_version configure.mpi=$mpi-$compiler-fortran || exit $port install yaml-cpp +$compiler +$mpi || exit $port install parmetis +$compiler +$mpi || exit $port install scotch +$compiler +$mpi || exit $port install hdf5-18 +$compiler +fortran +$mpi || exit $port install pnetcdf +$compiler +$mpi || exit $port install netcdf +$compiler +$mpi || exit $port install hdf5 +$compiler +fortran +$mpi || exit
Using the above outlined TPLs, the author has successfully built Trilinos and many applications requiring Trilinos (like Albany). Cmake and the TriBITs build system used by Trilinos take care of many of the Mac OS X specific build instructions. However, at the time of this writing the author has had the following issues:
- The stk package fails to build dynamic libraries.
- Many tests fail.