Compiling MRtrix with Json for modern C++


I am trying to install MRtrix on a CentOS HPC. I cannot use the conda pre-compiled version since I work with virtualenv and as much as I know they are mutually exclusive. Hence, I tried to compile it from the source.

However, when I run the configure script I get the result:

MRtrix build type requested: release version

Detecting OS: linux
Looking for compiler [clang++]: not found
Looking for compiler [g++]: g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Checking for C++11 compliance: ok
Checking shared library generation: ok
Detecting pointer size: 64 bit
Detecting byte order: little-endian
Checking for variable-length array support: ok
Checking for non-POD variable-length array support: ok
Checking for ::max_align_t: 16 bytes
Checking for std::max_align_t: not found
Checking for Eigen3 library: 3.3.9
Checking for Eigen3 Unsupported: Present
Checking for zlib compression library: 1.2.11
Checking for "JSON for Modern C++" requirements: 
ERROR: error compiling JSON for modern C++ application!

    MRtrix3 was unable to compile a test program involving JSON for modern C++.

  See the file 'configure.log' for details. If this doesn't help and you need
  further assistance, please post on the MRtrix3 community forum
  (, and make sure to include the full contents of
  the 'configure.log' file.

I looked at the log file and it is written:

REPORT: 1.2.11

REPORT: Checking for "JSON for Modern C++" requirements:

COMPILE /tmp/tmp8ni1ld_1.cpp:

#include "file/json.h"
int main (int argc, char* argv[])
  nlohmann::json json;
  json["key"] = "value";

CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -DMRTRIX_STD_MAX_ALIGN_T_NOT_DEFINED -DMRTRIX_HAVE_EIGEN_UNSUPPORTED_SPECIAL_FUNCTIONS -I/home/hers_ni/ycaspi/mrtrix3/core /tmp/tmp8ni1ld_1.cpp -o /tmp/tmp8ni1ld_1.o
In file included from /tmp/tmp8ni1ld_1.cpp:2:0:
/home/hers_ni/ycaspi/mrtrix3/core/file/json.h:66:10: error: #error "unsupported GCC version - see"
         #error "unsupported GCC version - see"

error deleting temporary file "/tmp/tmp8ni1ld_1.o": No such file or directory
ERROR: error compiling JSON for modern C++ application!

I tried to compile JSON for modern C++ , but I do not know how to link it to the configure script.

I also know about the thread:

Installation Problem, JSON requirements | Windows - #21 by jdtournier

I tried to use the command:

LD_PRELOAD=/usr/local/lib64/ MOC=/usr/bin/moc-qt5 QMAKE=/usr/bin/qmake-qt5 ./configure

With the libraries that I found on our HPC (qt4 instead of 5 and /, but it still does not work.

Any ideas on how to solve the problem and compile MRtrix?

Yaron Caspi

The issue is that the compiler you’re using is too old. You’re using:

But you’ll note in our installation instructions, we require GCC >= 5 (or clang).

If you’re on a HPC cluster, there’s a good chance you can load a more recent compiler using e.g. module load gcc/10.2.0 (type module avail to list available versions). Note this assumes your HPC administrator use the environment modules system to manage its packages, but this might not be the case on your HPC. Get in touch with your sysadmin if that doesn’t work.


This indeed solved the problem.
I am trying to compile it now with the TIFF PNG and FFTW libraries.

We do not have them on the HPC so I compiled them.

However, when I try to set:

export TIFF_CFLAGS="-LPATH_TO_TIFF/lib -lz"

export TIFF_LINKFLAGS="-isystem PATH_TO_TIFF/include"

and similar for libpng and FFTW, it does not work.

what is the correct way to pass these flags to the configure script.