Compile Error on Ubuntu 16.04

Dear mrtrix,

The following compile error occurs on Ubuntu 16.04. I guess the newer g++ is a bit more stringent about template syntax. If I manage to resolve this I will post the modifications to the code.

If you manage to resolve first, thanks in advance.

Nick

ERROR: ( 48/317) [CC] release/src/dwi/sdeconv/constrained.o

g++ -c -std=c++11 -pthread -fPIC -march=native -DMRTRIX_WORD64 -isystem /usr/include/eigen3 -Wall -O2 -DNDEBUG -Isrc -Icmd -I./lib -Icmd -isystem /usr/include/eigen3 src/dwi/sdeconv/constrained.cpp -o release/src/dwi/sdeconv/constrained.o

failed with output

In file included from ./lib/cmdline_option.h:28:0,
                 from ./lib/app.h:28,
                 from src/dwi/sdeconv/constrained.h:19,
                 from src/dwi/sdeconv/constrained.cpp:15:
./lib/mrtrix.h: In instantiation of std::__cxx11::string MR::str(const T&, int) [with T = Eigen::Transpose<Eigen::Matrix<double, -1, 1> >; std::__cxx11::string = std::__cxx11::basic_string<char>]:
src/dwi/sdeconv/constrained.h:98:15:   required from here
./lib/mrtrix.h:79:34: error: ambiguous template instantiation for struct MR::max_digits<Eigen::Transpose<Eigen::Matrix<double, -1, 1> >, int>
     else if (max_digits<T>::value())
                                  ^
./lib/mrtrix.h:65:12: note: candidates are: template<class X> struct MR::max_digits<X, typename std::enable_if<std::is_fundamental<typename X::Scalar>::value, int>::type> [with X = Eigen::Transpose<Eigen::Matrix<double, -1, 1> >]
     struct max_digits<X, typename std::enable_if<std::is_fundamental<typename X::Scalar>::value, int>::type> {
            ^
./lib/mrtrix.h:70:12: note:                 template<class X> struct MR::max_digits<X, typename std::enable_if<std::is_fundamental<typename X::value_type>::value, int>::type> [with X = Eigen::Transpose<Eigen::Matrix<double, -1, 1> >]
     struct max_digits<X, typename std::enable_if<std::is_fundamental<typename X::value_type>::value, int>::type> {
            ^
./lib/mrtrix.h:79:34: error: incomplete type MR::max_digits<Eigen::Transpose<Eigen::Matrix<double, -1, 1> >, int> used in nested name specifier
     else if (max_digits<T>::value())
                                  ^
./lib/mrtrix.h:80:47: error: incomplete type MR::max_digits<Eigen::Transpose<Eigen::Matrix<double, -1, 1> >, int> used in nested name specifier
         stream.precision (max_digits<T>::value());
                                               ^

Hi Nick, thanks for the report.

This one’s a bit of a double-whammy: the relevant MRtrix code is not quite as robust as it could be, but it’s actually highlighting a bug in whichever version of Eigen you have installed (which is what, out of curiosity?): typedef Scalar is not being defined in the Eigen::Transpose class.

Could you please checkout the str_precision_fix branch using git, and let me know if that fixes your compilation?

Cheers
Rob

Hi Rob

No luck with that branch unfortunately. My version of libeigen is:

$ sudo apt show libeigen3-dev 
Package: libeigen3-dev
Version: 3.3~beta1-2

Is there a way to pass a -k option to make via build.sh, then I can check if the issue is as localised (to one file) as I suspect.

Cheers
Nick

Here is a bit more info for reference:

git checkout -b str_precision_fix
Switched to a new branch 'str_precision_fix'

./configure

MRtrix build type requested: release

Detecting OS: linux
Checking for C++11 compliant compiler [g++]: 5.3.1 - tested ok
Detecting pointer size: 64 bit
Detecting byte order: little-endian
Checking for variable-length array support: yes
Checking for non-POD variable-length array support: yes
Checking for zlib compression library: 1.2.8
checking for Eigen 3 library: 3.2.92
Checking shared library generation: yes
Checking for Qt moc: moc (version 4.8.7)
Checking for Qt qmake: qmake (version 4.8.7)
Checking for Qt rcc: rcc (version 4.8.7)
Checking for Qt: 4.8.7

writing configuration to file './release/config': ok

OK, looks like you’ve got a beta development release of Eigen. I’d fall back to the latest stable release (3.2.8) and try again. If the 16.04 package manager doesn’t give you access to an earlier version, you may need to install it manually instead.

Regarding the str_precision_fix branch, can you post the compilation error for that as well?

SOLVED. Thank you Rob.

Switching to the stable version of eigen (3.2.8) does the trick.

Here are some instructions to install the older stable version (i.e. not the one in the universe repository):

wget http://bitbucket.org/eigen/eigen/get/3.2.8.tar.gz -O eigen-3.2.8.tar.gz
tar zxf eigen-3.2.8.tar.gz
cd eigen-eigen-07105f7124f9
mkdir Build
cd Build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
make
sudo make install
cd ../..
rm eigen-eigen-07105f7124f9 -rf

Cheers
Nick

Funny, that’s exactly the problem I was alluding to in this post)…

Just to close this off: there is now a fix for this on the master branch - you should no longer need to download an older version of Eigen, the latest version of MRtrix3 should now Just Work™…