Install AmberTools18 (amber18) on Mac OS X 10.14 (Mojave) using Homebrew (or not)

So after a fair bit of contemplating I made the decision to switch from MacPorts to Homebrew. This has not been a painless process and even if I like Homebrew, there are a number of caveats and I cannot for the life of me understand the motivation for implementing this “features”. Having this said, I am now fully committed to Homebrew and hence instructions for how to compile software will from now on out use Homebrew (or not).

With the recent update from OS X 13.X High Sierra to OS X 14.X Mojave a lot of things broke, as anticipated. This is something that I have now sadly come to expect from any update of the macOS. This did of course include the ability to compile amber on macOS. It turns out that, among other things, Apple decided that ”libstdc++” is deprecated and you should now use ”libc++” without leaving any backwards compatibility solution. Some other important files have also gone missing that used to reside in /usr/include/ that you now need to manually installed from an PKG installer buried in Xcode, this will however stop working with the next major Xcode release and undoubtedly brake a lot of other things as well. Long story short, this is what you need to do to compile AmberTools18/amber18 on macOS Mojave using Homebrew GCC8 or just using the macOS clang compiler. The journey resulting in this post is long and includes more issues than reported though I will not describe all of them since that would take a looooong time and would potentially not be very interesting for the general public.

Compile AmberTools18/amber18 using Homebrew GCC8

  1. Install Xcode and Command Line Tools
    Xcode10 is most appropriately installed from the AppStore
    You need to install Command Line Tools manually by executing the following in Terminal.app
    sudo xcode-select --install

  2. Install Homebrew and GCC
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    brew install gcc

  3. Install missing header files
    In Terminal.app, run the following command to open the PKG installer and follow the instructions.
    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

  4. Download the AmberTools18/amber18 archives and extract them where you want to install them.
    tar xvf AmberTools18.tar.bz2

  5. Configure and install
    export AMBERHOME=/[PATH]/[TO]/amber18
    export PATH=${AMBERHOME}:$PATH
    cd $AMBERHOME
    export MACOSX_DEPLOYMENT_TARGET='10.14'
    Eliminates an error: "cannot find <include> file".
    ln -s /usr/local/bin/gcc-8 /usr/local/bin/gcc
    ln -s /usr/local/bin/g++-8 /usr/local/bin/g++
    ln -s /usr/local/bin/c++-8 /usr/local/bin/c++
    ./configure -macAccelerate gnu
    make install

This will produce a working version of AmberTools18/amber18 using Homebrew GCC8 though there are still issues and there will undoubtedly be more issues that will surface before everything works as intended.

Compile AmberTools18/amber18 using macOS clang

  1. Install Xcode and Command Line Tools
    Xcode10 is most appropriately installed from the AppStore
    You need to install Command Line Tools manually by executing the following in Terminal.app
    sudo xcode-select --install

  2. Install the missing header files
    In Terminal.app, execute the following command to launch the PKG installer and follow the instructions.
    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

  3. Download AmberTools18/amber18 archives and extract where you want to install.
    tar xvf AmberTools18.tar.bz2

  4. Configure and install
    export AMBERHOME=/[PATH]/[TO]/amber18
    export PATH=${AMBERHOME}:$PATH
    cd $AMBERHOME
    export MACOSX_DEPLOYMENT_TARGET='10.14'
    Eliminates an error: "cannot find <include> file".
    vi $AMBERHOME/AmberTools/src/configure2
    Comment out rows 2237-2241
    # if [ "$intelmpi" = 'yes' ]; then
    # echo "Intel MPI must be used with the Intel compilers."
    # exit 1
    # fi
    #


    vi $AMBERHOME/AmberTools/src/pytraj/setup.py
    Change libstdc++ to libc++ on row 142
    142 extra_compile_args.append('-stdlib=libstdc++’)
    --->
    142 extra_compile_args.append('-stdlib=libc++’)



    Also change the same on rows 2289-2293
    2289 # mac/clang
    2290 if [ "$skippython" = "no" ]; then
    2291 cpptrajcxxflags="-stdlib=libstdc++ $cpptrajcxxflags"
    2292 cpptrajldflags="-stdlib=libstdc++ -L/usr/lib/"
    2293 fi
    --->
    2289 # mac/clang
    2290 if [ "$skippython" = "no" ]; then
    2291 cpptrajcxxflags="-stdlib=libc++ $cpptrajcxxflags"
    2292 cpptrajldflags="-stdlib=libc++ -L/usr/lib/"
    2293 fi


    ./configure -macAccelerate clang
    make install

This produces a working version of AmberTools18/amber18 using macOS clang though there are still issues and there will, without a doubt, be more issues that will surface.

Leave a Reply

Your email address will not be published. Required fields are marked *