Installation Problem, JSON requirements | Windows


#21

Yes, so that sounds like a similar problem. I’m guessing you’re compiling MRtrix with a non-default compiler? What might be happening is that the MRtrix executables are compiled for a certain version of the c++ standard library (matching your compiler), but at runtime, the system’s default version is used. It’s a similar issue in that the fix is likely to be to somehow modify the linker search path to include the non-default version first. But you probably also want to avoid other non-MRtrix commands using the custom version, so it’s probably not a good idea to make that the system-wide default. So it’s a tricky one to handle…

Thankfully, I reckon there might be a relatively easy fix – assuming I’ve got this right. Normally you’d be adding an entry to the /etc/ld.so.conf file (or ld.so.conf.d/ folder) with the path to the folder containing your compiler’s libraries, but that’ll set it system-wide (all users). Another approach is to add that location to the LD_LIBRARY_PATH environment variable, which will set it for that session only – better, but other non-MRtrix commands in that session might be affected (and besides, that approach is generally frowned upon for security reasons). So still not ideal.

I think your best bet will be to create a symbolic link to the right library in the MRtrix3 lib/ folder – our executables are hard-coded to look there first, to make sure they find the right version of the MRtrix3 library (libmrtix-3.0_RC2.so or similar), which means that any libraries placed here will be used in preference to the system ones – but only for our executables, just what we want…

To do this, first check where your compiler is (it should say near the top of configure.log), and check what libraries are actually being used at runtime (e.g. ldd bin/mrinfo). I’m guessing you’ll find that it’s trying to use the libstdc++.so from the standard location (e.g. /usr/lib), when your compiler would have installed its version elsewhere (e.g. if the compiler used was /usr/local/bin/g++, I’d expect the library to be /usr/local/lib/libstdc++.so). If you figure out where it is exactly, you can try to create a symbolic link to it within the MRtrix3 lib/ folder like this:

cd lib
ln -s /usr/local/lib/libstdc++.so`
cd ..

At which point, check whether the command now works, and whether the linker finds the right version of the library this time (ldd bin/mrinfo once again).

Hope that at least points you in the right direction…


Building mrtrix3 on RHEL 7
#22

Hi JD,

Thank you for your detailed response. I guess my question was not entirely clear; this problem turns up right away when configuring.

[martijn@localhost mrtrix3]$ ./configure

MRtrix build type requested: release

Detecting OS: linux
Looking for compiler [clang++]: not found
Looking for compiler [g++]: g++ (GCC) 5.4.0
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: not found
Checking for ::max_align_t: 16 bytes
Checking for std::max_align_t: 16 bytes
Checking for Eigen3 library: 3.2.5
Checking for zlib compression library: 1.2.7
Checking for "JSON for Modern C++" requirements: 
ERROR: runtime error!
  
   Unable to configure 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
  (http://community.mrtrix.org/), and make sure to include the full contents of
  the 'configure.log' file.

The configure.log tells me that the configuration process fails because of the following error.

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

COMPILE /tmp/tmpWYwJ_R.cpp:
---

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

---
EXEC <<
CMD: g++ -c -std=c++11 -pthread -fPIC -DMRTRIX_WORD64 -DMRTRIX_NO_NON_POD_VLA -I/home/martijn/apps/mrtrix3/core /tmp/tmpWYwJ_R.cpp -o /tmp/tmpWYwJ_R.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpWYwJ_R.o -pthread -lz -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 1
STDERR:
./a.out: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./a.out)
>>


ERROR: runtime error!
  
   Unable to configure 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
  (http://community.mrtrix.org/), and make sure to include the full contents of
  the 'configure.log' file.

It should be said that I updated the system GCC to 5.4.0 because the default 4.8 is too old for compiling Mrtrix (that’s what the documentation said).

I also tried to compile with devtoolset 7, but then the configure script fails even earlier.

Best,
Martijn


#23

Okay, it turns out that the following command solved the issue:

LD_PRELOAD=/usr/local/lib64/libstdc++.so.6.0.21 MOC=/usr/bin/moc-qt5 QMAKE=/usr/bin/qmake-qt5 ./configure

Thanks for thinking with me.


#24

Ok, good to hear. Bear in mind that this LD_PRELOAD will be needed for every MRtrix command invocation… I would still recommend placing a symbolic link to that library in the MRtrix lib/ folder, which would avoid that.

Also, just realised that this trick only works at runtime, once the executables have already been built – you would indeed have needed other strategies to configure and build… If that trick works, all the better!


#25

Ok, good to hear. Bear in mind that this LD_PRELOAD will be needed for every MRtrix command invocation… I would still recommend placing a symbolic link to that library in the MRtrix lib/ folder, which would avoid that.

Yes, that’s what I just found out. Thanks!