<> = Getting the source code = To obtain the source code for the latest FSL release, simply install FSL by using the `fslinstaller.py` script, as outlined on the [[FslInstallation|main installation page]]. The source code for the release will be installed into `$FSLDIR/src/`. The source code for each FSL sub-project is also publicly available on the FMRIB !GitLab server, at https://git.fmrib.ox.ac.uk/. = Compiling FSL projects = A FSL installation contains software written in a variety of programming languages - these instructions describe how to compile a FSL sub-project that is written in C/C++. FSL release are compiled in a modular fashion - each FSL sub-project is compiled separately, using the [[https://docs.conda.io/en/latest/|conda]] package manager. The C/C++ portions of a FSL release are compiled using the C++ compiler toolchain from [[https://conda-forge.org/|conda-forge]], which is installed as part of a standard FSL release. FSL projects can, however, be compiled locally without using conda, and with a compiler of your choice. FSL projects use a simple `Makefile`-based build system which is implemented in the [[https://git.fmrib.ox.ac.uk/fsl/base|fsl-base]] project. The common make rules used by all FSL projects can be found within the `$FSLDIR/config/` directory. The steps below describe how to compile the [[https://git.fmrib.ox.ac.uk/fsl/avwutils|avwutils]] project (which provides `fslmaths`, `fslstats`, and a range of other utilities). You can follow a similar process to compile other projects. 1. Set up your shell environment for compilation by running these commands in your shell: {{{ # Normal FSL shell setup - this may have # already been done in your shell profile, # so may not need to be repeated here. # # export FSLDIR=/home//fsl # PATH=${{FSLDIR}}/share/fsl/bin:${{PATH}} # export FSLDIR PATH # . ${{FSLDIR}}/etc/fslconf/fsl.sh # Set the FSLDEVDIR environment variable # to a location of your choice - if you # install any hand-compiled software, it # will be installed into this directory. # # If you are planning to install and run # your own versions of FSL binaries, # you may wish to add $FSLDEVDIR/bin/ # to your $PATH variable. export FSLDEVDIR=/home//fsl-dev # Source the fsl-devel.sh script - this # sets some additional FSL environment # variables needed for compilation. source $FSLDIR/etc/fslconf/fsl-devel.sh # Activate the FSL conda environment - # this step will make the conda-forge # C++ compiler toolchain available on # your $PATH. # # You also have the option of using # a different compiler toolchain - in # this case you will *not* want to # perform this step - instead, you # need to make sure that your compiler # tools are available on your $PATH, # or are specified by standard make # variables such as $CC, $CXX, etc. source $FSLDIR/bin/activate -p $FSLDIR }}} 2. Obtain the avwutils source code - you have the choice of compiling the source code that came with your FSL installation (inside `$FSLDIR/src/fsl-avwutils/`), or cloning the latest version from the [[https://git.fmrib.ox.ac.uk/fsl/avwutils|avwutils gitlab repository]], for example: {{{ git clone https://git.fmrib.ox.ac.uk/fsl/avwutils.git }}} 3. Change into the source directory, and run `make`. This will compile the avwutils source code, and create `fslmaths`, `fslstats`, etc binaries within the source directory: {{{ cd avwutils make # If you would like to install the newly # compiled binaries into `$FSLDEVDIR`: make install }}} = Compiling CUDA projects = To compile CUDA-capable projects such as `eddy` or `probtrackx2_gpu`, some additional steps are required. Note that you do '''not''' need a GPU in order to compile CUDA programs (but you do need a GPU to run them). 1. You must first install a copy of the CUDA Toolkit - this can be downloaded from https://developer.nvidia.com/cuda-toolkit. By default, the CUDA Tooklit will be installed into `/usr/local/cuda-X.Y/` (where `X.Y` is the CUDA version), but the installation locataion can be customised. 2. You then need to ensure that the `/bin/` directory is available on your `$PATH`, so that the `nvcc` compiler driver can be found. 3. Now follow the steps outlined above for compiling a FSL project. Certain CUDA projects have additional options that need to be specified when calling `make` - refer to the project `Makefile` for more details. For example, to compile [[https://git.fmrib.ox.ac.uk/fsl/eddy|eddy]]: {{{ git clone https://git.fmrib.ox.ac.uk/fsl/eddy.git cd eddy make cuda=1 }}} = More information = More information on compiling FSL projects, and on the development and release workflows used for FSL, can be found at https://git.fmrib.ox.ac.uk/fsl/conda/docs/.