General guidance for Mac OS X.
Compiling GCC 10 on macOS Mojave Posted on May 21, 2017 by Paul. Updated 29 May 2020. In this tutorial, I will show you how to compile from source and install the current stable version of GCC on your macOS computer. Homebrew: On the newer Macbooks with the Apple M1 processor, look for g in /opt/homebrew/Cellar/gcc instead of /usr/local/Cellar/gcc. Gnu Gcc Compiler Download Mac Os X64 Grab the latest archive of the GNU compilers from the HPC on Mac OS X site; In Terminal.app, change directories to where the GCC file was downloaded (usually, /Downloads) If your browser didn't automatically unzip the file (still zipped if the file ends with.gz), you can unzip the file by typing.
The Dakota team has discovered two methods of installing Dakota's dependencies on OS X.
- Using the homebrew package manager. This is the easier option for most users. Setup using homebrew.
- Downloading and installing all required dependencies spearately. This is the historical method. Setup the historical method.
Notes: Mac SIP can be highly problematic when running Dakota tests or even using the Dakota binaries. Also make sure if you build your own toolchains that the TPLs are built with the compiler you intend to use for Dakota and not the system compiler. It may be necessary in addition to enable C++11 when compiling Boost, particularly with GCC compilers.
Setup Using Homebrew
Verified September 2017 on OS X Sierra 10.12. All libraries and tools will be installed using the homebrew package manager.
- Follow the instructions on the homebrew website to install the homebrew package manager.
- Install gcc@5, which includes all needed compilers, with the command
- Install CMake with the command
- Install Boost 1.55. It is necessary to instruct brew to build Boost from source using the gcc-5 compiler.
- Optional (needed for message-passing parallelism): Install OpenMPI 1.6, building it from source, too.
- Optional (needed to use bayes_calibration queso): GSL 1.16 from source.
Setup Using the Historical Method
An example system setup process follows. In general, we satisfy Dakota's requirements with the following:
- CMake 2.8.12 or newer: install DMG binary
- GNU compilers, including gcc, g++, and gfortran from http://hpc.sourceforge.net/
- Boost 1.50.0 or newer (1.53.0 recommended): compiled from source using the above compilers (not system compilers).
- Linear Algebra: stock OS X vecLib Framework suffices
- OpenMPI: compile from source if desired
- X Windows: unknown
Notes:
- Apple provides C and C++ compilers with the operating system and XCode Command Line Tools; however they do not offer a Fortran compiler, and it can be challenging to install a compatible one. Take care not to errantly configure Dakota with a mixture of system-provided gcc or clang, and your custom-installed tools.
- Moreover, not all Dakota packages (most notably Acro) support LLVM/Clang, which is the default system compiler in more recent versions of OS X.
- You may alternately choose to satisfy Dakota's requirements via your package manager such as Fink, Homebrew, MacPorts, etc., but must use a consistent toolchain throughout the TPL and Dakota build processes.
- If attempting to use system-installed LLVM compiler, make sure to build boost, MPI, etc. with this toolchain too
- Mountain Lion (10.8.x): gcc front-end to LLVM; success mixing tool chains using /usr/bin/gcc, /usr/bin/g++ and /usr/local/bin/gfortran from hpc.sourceforge.net
- Needed CMAKE_CXX_FLAGS=-fdelayed-template-parsing
- Mavericks (10.9.x): clang front-end to LLVM; success using gfortran from home-brew
- Mountain Lion (10.8.x): gcc front-end to LLVM; success mixing tool chains using /usr/bin/gcc, /usr/bin/g++ and /usr/local/bin/gfortran from hpc.sourceforge.net
Example Setup Process
Gcc Download Mac Os X
Last verified October 2014 on Mavericks, 10.9.x; March 2015 on Mountain Lion, 10.8.x; September 2017 on Sierra, 10.12. This example is a representative way to satisy Dakota dependencies on Mac OS X Mountain Lion, Mavericks, or Sierra. We offer it in hopes it is useful, though it is not the only and perhaps not the fastest way to meet the requirements.
Gnu Gcc Compiler Download Mac Os X
- CMake: Download and install CMake 2.8.12 or newer 2.x Darwin universal DMG from http://www.cmake.org/download. For example, https://cmake.org/files/v2.8/cmake-2.8.12.2-Darwin64-universal.dmg. Choose option to install to /usr/local/bin when asked.
- XCode: (Required prerequisite for the following recommended GNU compilers)
- If Xcode is not pre-installed on your Mac, you can install it using Apple's Mac App Store, or from https://developer.apple.com/xcode. Note: make sure to create your own Apple credentials and use them to log in to the App Store when downloading Xcode, so that MAC can identify you as the same logged-in user.
- Install command-line tools: Open the Xcode application and install command-line tools (Preferences > Downloads > Command Line Tools). Or, for newer versions, run xcode-select --install
From http://hpc.sourceforge.net/: You will also need to have Apple's XCode Tools installed from the Mac App Store. With XCode 4, 5 or 6 you will need to download the command-line tools as an additional step. You will find the option to download the command-line tools in XCode's Preferences. - Apply any needed software updates to OS X and XCode, and check for updates to command-line tools.
- GNU Compilers: A compiler toolchain, with compatible Fortran support is needed; see note above about LLVM/Clang. We recommend the following process:
- Download the appropriate version from http://hpc.sourceforge.net/, e.g., gcc-4.8-bin.tar.gz for Mountain Lion or gcc-4.9-bin.tar.gz for Mavericks.
- Open a Terminal and unpack into a suitable location, such as your home directory:
Add these compilers to .bashrc
- Execute source ~/.bashrc in your Terminal before proceeding. Verify correct compilers are found (the ones just installed), and make sure any of the following compilation steps use these compilers.
- Boost portable C++ libraries: compile from source
- Download Boost source from: http://sourceforge.net/projects/boost/files/boost
- Recommended version: 1.51.0 (boost-1-51-0.tar.gz)
- Note: Boost needs to know where your compiler is, in order to install successfully, and to avoid an issue where invalid options are passed to the linker when specifying toolset gcc. If you installed a new version of g++, you can update user-config.jam in your home directory to the right gcc path:
- To compile and install Boost, run the following script in your terminal. Check TODO LINK for current required Boost libaries and add any that are missing:
- Add to .bashrc:
- OpenMPI (optional): If compiling Dakota with MPI enabled:
- Download a recent version of OpenMPI, e.g., http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.5.tar.gz and unpack, compile, and install:
- Make necessary environment additions in $HOME/.bashrc:
- Download a recent version of OpenMPI, e.g., http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.5.tar.gz and unpack, compile, and install:
- GSL (optional, required for Dakota's QUESO feature):
- Download from http://ftpmirror.gnu.org/gsl/gsl-1.16.tar.gz
- Compile and install. Make necessary environment additions.