FreeSurfer Build Guide
This page walks through the process of building the FreeSurfer source code and creating a distribution. For an introduction to the repository and the development process, visit the Dev Guide.
Freesurfer is supported on OSX El Capitan (10.11) and later, and we recommend using the brew package manager to install a few of the build dependencies:
brew install cmake gcc5 glib brew install qt5 # optional (for building GUIs)
The remaining dependencies can be built locally using the build_packages.sh freesurfer script, or they can just be downloaded as prebuilt packages (recommended). The following will create a packages directory containing a set of required freesurfer dependencies (built on OS X 10.11.6):
curl tar -xzvf
get source from github or fork --
get annex data --
Freesurfer supports both in-source and out-of-source builds using CMake (although tests can only be run from an in-source build). To configure a simple in-source build tree, enter the top-level directory of the repository and run:
External users not developing on the Martinos filesystem will get an error saying "". To resolve this, you must point cmake to the full path of the packages directory configured above with the following flag:
cmake . -DFS_PACKAGES_DIR="/path/to/packages"
This path can also be set in an FS_PACKAGES_DIR environment variable, so that it doesn't need to be supplied on the command line for every new configuration.
By default, freesurfer will install to /usr/local/freesurfer, but the install path can be configured with:
cmake . -DCMAKE_INSTALL_PREFIX="/path/to/desired/install"
Alternatively, this path can be set in an FS_INSTALL_DIR environment variable to avoid having to specify it for every configuration.
Optimization and Debugging
Once your build tree has been configured appropriately, freesurfer can be compiled with make and installed with make install. Additionally, unit and regression tests can be run with make test (previously make check) from individual subdirectories or from the top-level.
The current 8-threaded build time is roughly 6 minutes. Single-threaded builds can take between ? and ? minutes.