Ubuntu 18 and g++ -7: problems with C++11 compliance

#1

Hi all,

I am having problems trying to intall mrtrix3 on my ubuntu 18.04 manchine. I have tried setting the CXX variable to: my copies of g++ -5, g++ -7, and clang -4.0. All of these options retuned the same error:

MRtrix build type requested: release version

WARNING: Anaconda removed from PATH to avoid conflicts

Detecting OS: linux
Looking for compiler [/usr/bin/g++]: g++ (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
Checking for C++11 compliance: test failed (see configure.log for details)


ERROR: no suitable compiler found!



  Set the CXX environment variable to inform 'configure' of the path to the
  compiler on your system, as follows:
    $ export CXX=/usr/bin/g++-5.5
    $./configure
  (amend with the actual path to the compiler on your system)

  If you are using a compiler other than gcc or clang, you can also set the CXX_ARGS
  environment variable to specify how your compiler expects different arguments
  to be presented on the command line, for instance as follows:
    $ export CXX_ARGS="-c CFLAGS SRC -o OBJECT"
    $ ./configure


  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.

I am stucked trying to figure out how to compile mrtrix3 as I am a fairly new linux user. I would greatly apreciate any help.

Here is the content of my configure.log file:

REPORT: g++ (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

REPORT: Checking for C++11 compliance:

COMPILE /tmp/tmpw1m7k36i.cpp:
---

#include <cstddef>
struct Base {
    Base (int);
};
struct Derived : Base {
    using Base::Base;
};

int main() {
  Derived D (int); // check for contructor inheritance
  return 0;
}

---
EXEC <<
CMD: /usr/bin/g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe /tmp/tmpw1m7k36i.cpp -o /tmp/tmpw1m7k36i.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-ld /tmp/tmpw1m7k36i.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 1
STDERR:
/home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-ld: unrecognized option '-Wl,--sort-common,--as-needed'
/home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-ld: use the --help option for usage information
>>

error deleting temporary file "a.out": No such file or directory
REPORT: test failed (see configure.log for details)

ERROR: no suitable compiler found!



  Set the CXX environment variable to inform 'configure' of the path to the
  compiler on your system, as follows:
    $ export CXX=/usr/bin/g++-5.5
    $./configure
  (amend with the actual path to the compiler on your system)

  If you are using a compiler other than gcc or clang, you can also set the CXX_ARGS
  environment variable to specify how your compiler expects different arguments
  to be presented on the command line, for instance as follows:
    $ export CXX_ARGS="-c CFLAGS SRC -o OBJECT"
    $ ./configure


  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.

#2

Sounds like this issue. Anaconda does a lot of things behind the scenes that typically cause trouble, to the extent that we strip it out of the PATH to avoid conflicts (lots of examples of that if you search on this forum).

It does however seem to be possible to build MRtrix3 with the anaconda compiler, but you’ll need to undo a few things first. In this instance, I think all you need to do is unset the LD environment variable before invoking ./configure

#3

Thank you for the quick resonpse @jdtournier. I really appreciate the help. Unseting the LD enviroment variable helped me get pass the C++11 compliance issue.

Unfortuantelly, I am now stuck trying to find the zlib library. I did make sure to double check that the zlib1g-dev library was isntalled but I am still getting the following error:

MRtrix build type requested: release version

WARNING: Anaconda removed from PATH to avoid conflicts

Detecting OS: linux
Machine architecture set by ARCH environment variable to: native
Looking for compiler [/home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++]: x86_64-conda_cos6-linux-gnu-c++ (crosstool-NG 1.23.0.449-a04d0) 7.3.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: ok
Checking for ::max_align_t: 16 bytes
Checking for std::max_align_t: 16 bytes
Checking for Eigen3 library: 3.3.4
Checking for zlib compression library: 
ERROR: error compiling zlib application!

    MRtrix3 was unable to compile a test program involving zlib.

  Set the ZLIB_CFLAGS environment variable to inform 'configure' of
  the flags it must provide to the compiler in order to compile
  programs that use zlib functionality; this may include the path to
  the zlib include files, as well as any required flags.
  For example:
    $ export ZLIB_CFLAGS="-isystem /usr/local/include"
    $./configure
  (amend with the actual path to the zlib include files on your system)

with this configure.log:


REPORT: 
MRtrix build type requested: release version

REPORT: WARNING: Anaconda removed from PATH to avoid conflicts

REPORT: Detecting OS: linux

REPORT: Machine architecture set by ARCH environment variable to: native

REPORT: Looking for compiler [/home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++]:
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ --version
EXIT: 0
STDOUT:
x86_64-conda_cos6-linux-gnu-c++ (crosstool-NG 1.23.0.449-a04d0) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>


REPORT: x86_64-conda_cos6-linux-gnu-c++ (crosstool-NG 1.23.0.449-a04d0) 7.3.0

REPORT: Checking for C++11 compliance:

COMPILE /tmp/tmp19z3189i.cpp:
---

#include <cstddef>
struct Base {
    Base (int);
};
struct Derived : Base {
    using Base::Base;
};

int main() {
  Derived D (int); // check for contructor inheritance
  return 0;
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe /tmp/tmp19z3189i.cpp -o /tmp/tmp19z3189i.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmp19z3189i.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok

REPORT: Checking shared library generation:
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe /tmp/tmpi6h83ncu.cpp -o /tmp/tmpi6h83ncu.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmpi6h83ncu.o -shared -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o libtest.so
EXIT: 0
>>


REPORT: ok

REPORT: Detecting pointer size:

COMPILE /tmp/tmpoyjrj8ax.cpp:
---

#include <iostream>
int main() {
  std::cout << sizeof(void*);
  return (0);
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe /tmp/tmpoyjrj8ax.cpp -o /tmp/tmpoyjrj8ax.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmpoyjrj8ax.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
8
>>


REPORT: 64 bit

REPORT: Detecting byte order:

REPORT: little-endian

REPORT: Checking for variable-length array support:

COMPILE /tmp/tmp561xla2r.cpp:
---

int main(int argc, char* argv[]) {
  int x[argc];
  return 0;
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -DMRTRIX_WORD64 /tmp/tmp561xla2r.cpp -o /tmp/tmp561xla2r.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmp561xla2r.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok

REPORT: Checking for non-POD variable-length array support:

COMPILE /tmp/tmpo_im6a_3.cpp:
---

#include <string>

class X {
  int x;
  double y;
  std::string s;
};

int main(int argc, char* argv[]) {
  X x[argc];
  return 0;
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -DMRTRIX_WORD64 /tmp/tmpo_im6a_3.cpp -o /tmp/tmpo_im6a_3.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmpo_im6a_3.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok

REPORT: Checking for ::max_align_t:

COMPILE /tmp/tmps2dq795y.cpp:
---

#include <iostream>
#include <cstddef>
using ::max_align_t;
int main() {
  std::cout << alignof (max_align_t) << " bytes\n";
  return 0;
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -DMRTRIX_WORD64 /tmp/tmps2dq795y.cpp -o /tmp/tmps2dq795y.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmps2dq795y.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
16 bytes
>>


REPORT: 16 bytes

REPORT: Checking for std::max_align_t:

COMPILE /tmp/tmp9yfypw6s.cpp:
---

#include <iostream>
#include <cstddef>
using std::max_align_t;
int main() {
  std::cout << alignof (max_align_t) << " bytes\n";
  return 0;
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -DMRTRIX_WORD64 /tmp/tmp9yfypw6s.cpp -o /tmp/tmp9yfypw6s.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmp9yfypw6s.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
16 bytes
>>


REPORT: 16 bytes
EXEC <<
CMD: pkg-config --cflags eigen3
EXIT: 0
STDOUT:
-I/usr/include/eigen3
>>


REPORT: Checking for Eigen3 library:

COMPILE /tmp/tmp3u5d9wa5.cpp:
---

#include <cstddef>
#include <Eigen/Core>
#include <iostream>

int main (int argc, char* argv[]) {
  std::cout << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << "\n";
  return 0;
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -DMRTRIX_WORD64 -isystem /usr/include/eigen3 /tmp/tmp3u5d9wa5.cpp -o /tmp/tmp3u5d9wa5.o
EXIT: 0
>>

EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ /tmp/tmp3u5d9wa5.o -Wl,--sort-common,--as-needed -pthread -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
3.3.4
>>


REPORT: 3.3.4
EXEC <<
CMD: pkg-config --cflags zlib
EXIT: 0
>>

EXEC <<
CMD: pkg-config --libs zlib
EXIT: 0
STDOUT:
-lz
>>


REPORT: Checking for zlib compression library:

COMPILE /tmp/tmpfoco_h35.cpp:
---

#include <iostream>
#include <zlib.h>

int main() {
  std::cout << zlibVersion();
  return (0);
}

---
EXEC <<
CMD: /home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -march=native -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -DMRTRIX_WORD64 /tmp/tmpfoco_h35.cpp -o /tmp/tmpfoco_h35.o
EXIT: 1
STDERR:
/tmp/tmpfoco_h35.cpp:3:10: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
          ^~~~~~~~
compilation terminated.
>>

error deleting temporary file "/tmp/tmpfoco_h35.o": No such file or directory
ERROR: error compiling zlib application!

    MRtrix3 was unable to compile a test program involving zlib.

  Set the ZLIB_CFLAGS environment variable to inform 'configure' of
  the flags it must provide to the compiler in order to compile
  programs that use zlib functionality; this may include the path to
  the zlib include files, as well as any required flags.
  For example:
    $ export ZLIB_CFLAGS="-isystem /usr/local/include"
    $./configure
  (amend with the actual path to the zlib include files on your system)

After searching for possible solutions on the forum I have tried to set a ZLIB_CFLAGS environment variable, upgrade and dwngrade my nvidia drivers without much luck.

Again, I would greatly apreciate any help you can provide.

Best,

Luis

Note for other novice linux users: I just had to type the following comand on the terminal to temporarly unset the LD enviroment variable:

unset LD

#4

So that’s exactly the kind of problem you’ll encounter when trying to use Anaconda to build MRtrix3: conflicts between the Anaconda-supplied packages and the system-supplied ones. Using the Anaconda compiler means it’ll most likely be set up to ignore the system libraries and expect to use Anaconda versions of everything. What I don’t quite understand is why it’s using the Anaconda compiler at all – and it clearly is, as you can see from the logs (/home/lralvarado/anaconda3/bin/x86_64-conda_cos6-linux-gnu-c++). As you can see from the initial warning (WARNING: Anaconda removed from PATH to avoid conflicts), we try to avoid this kind of situation, but here for some reason, you still end up with the wrong version of the compiler… Maybe you need to unset the CXX environment variable too…?

#5

Again, thank you for the help!

I am not sure why anaconda is still being use. Unsetting CXX environment variable got me past the Zlib error.
I am getting a QT modules error. It seems like the configure script is not recogningsing teh svg QT module.

MRtrix build type requested: release version

WARNING: Anaconda removed from PATH to avoid conflicts

Detecting OS: linux
Machine architecture set by ARCH environment variable to: native
Looking for compiler [clang++]: clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
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: 16 bytes
Checking for Eigen3 library: 3.3.4
Checking for zlib compression library: 1.2.11
Checking for "JSON for Modern C++" requirements: ok
Checking for TIFF library: LIBTIFF, Version 4.0.9
Checking for FFTW library: fftw-3.3.7-sse2-avx
Checking for Qt moc: moc (version 5.9.5)
Checking for Qt qmake: qmake (version 5.9.5)
Checking for Qt rcc: rcc (version 5.9.5)
Checking for Qt: 
ERROR: qmake returned with error:

Project ERROR: Unknown module(s) in QT: svg


ERROR: unexpected exception!

  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.

I think I found a solutin to the QT module problem on a stack overflow thread:

I enter the following comand on my terminal and it fixed the problem

sudo apt-get install libqt5svg5*

#6

In sum, after dowloading the MRtrix3 repository, I had to unset the LD and CXX variables and install the Qt5Svg library as follows:

git clone https://github.com/MRtrix3/mrtrix3.git
cd mrtrix3
unset LD
unset CXX
sudo apt-get install libqt5svg5*
./configure

to the get following output

WARNING: Anaconda removed from PATH to avoid conflicts

Detecting OS: linux
Machine architecture set by ARCH environment variable to: native
Looking for compiler [clang++]: clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
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: 16 bytes
Checking for Eigen3 library: 3.3.4
Checking for zlib compression library: 1.2.11
Checking for "JSON for Modern C++" requirements: ok
Checking for TIFF library: LIBTIFF, Version 4.0.9
Checking for FFTW library: fftw-3.3.7-sse2-avx
Checking for Qt moc: moc (version 5.9.5)
Checking for Qt qmake: qmake (version 5.9.5)
Checking for Qt rcc: rcc (version 5.9.5)
Checking for Qt: 5.9.5

writing configuration to file './config': ok

Thank you @jdtournier for your time and help!

Best,

Luis

1 Like