FreeSurfer Build Requirements

Freesurfer depends on a variety of third-party libraries, and this page recommends the best ways to install these dependencies on linux and mac. For further instructions on compiling freesurfer, visit the build guide.

Ubuntu

On ubuntu/debian, install a few of the required tools and libraries with apt-get:

sudo apt-get -y update
sudo apt-get -y install git wget tcsh build-essential gfortran
sudo apt-get -y install libblas-dev liblapack-dev zlib1g-dev
sudo apt-get -y install libxmu-dev libxmu-headers libxi-dev libxt-dev libx11-dev libglu1-mesa-dev

Ideally, freesurfer should be compiled with gcc 4.8 (and not anything newer than gcc 5). To install gcc 4.8 on newer versions of ubuntu, run:

apt-get -y install gcc-4.8 g++-4.8 gfortran-4.8
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 48 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.8 --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-4.8
update-alternatives --config gcc  # choose gcc-4.8

CentOS

On centos/redhat, install a few of the required tools and libraries with yum:

sudo yum update
sudo yum install git wget tcsh gcc gcc-c++ libgfortran-static make vim-common
sudo yum install lapack-devel lapack-static blas-devel blas-static zlib-devel
sudo yum install libX11-devel libXmu-devel mesa-libGL-devel

Further Linux Requirements

On some older linux distributions, package managers might only provide cmake v2, but version 3.9+ is required. The following will build and install cmake 3.12:

wget https://cmake.org/files/v3.12/cmake-3.12.0.tar.gz
tar -xzvf cmake-3.12.0.tar.gz && cd cmake-3.12.0
./bootstrap
make -j4
sudo make install
cd .. && rm -rf cmake-3.12.0 cmake-3.12.0.tar.gz

Additionally, python 3.5 or greater is required to configure and build freesurfer. If you don't have python3 installed, we recommend using anaconda python, which can be downloaded from https://www.anaconda.com/distribution.

The remaining dependencies, like vtk and itk, 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 centos7). Make sure you point cmake to your packages directory when configuring freesurfer as described in the build guide.

wget https://surfer.nmr.mgh.harvard.edu/pub/data/fspackages/prebuilt/centos7-packages.tar.gz
tar -xzvf centos7-packages.tar.gz

MacOS

Freesurfer is supported on OSX El Capitan (10.11) and later, and we recommend using the homebrew package manager to install a few of the build dependencies:

brew install gcc5 cmake tcsh

Python 3.5 or greater is required to configure and build freesurfer. If you don't have python3 installed, we recommend using anaconda python, which can be downloaded from https://www.anaconda.com/distribution.

The remaining dependencies, like vtk and itk, 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). Make sure you point cmake to your packages directory when configuring freesurfer as described in the build guide.

curl https://surfer.nmr.mgh.harvard.edu/pub/data/fspackages/prebuilt/osx10.11-packages.tar.gz -o osx10.11-packages.tar.gz
tar -xzvf osx10.11-packages.tar.gz

A Note Regarding FreeSurfer GUIs

The freesurfer GUIs, like freeview, are developed using the Qt framework, which we don't distribute in the prebuilt packages (for various reasons). Unless you'd like to build the GUIs, we'd recommend configuring the build with the cmake variable BUILD_GUIS set to OFF to avoid the Qt requirement.