Installing with QT 4 on a machine with multiple QT installations

When I wanted to compile on a machine with multiple QT installations I tried to prepend QT_SELECT=4 to my ./configure command.

Unfortunately I got this error in the ./build step:

Do I have to provide additional QT compilation flags?

Thanks for your help

The reason for the selection of QT4 is that when I don’t select a specific version the compiler just uses Qt5 and succeeds but upon trying to opening the binary I get the following error:

bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/ version `Qt_5_PRIVATE_API' not found (required by /usr/lib/x86_64-linux-gnu/
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/ version `Qt_5.9' not found (required by /usr/lib/x86_64-linux-gnu/
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/ version `Qt_5' not found (required by /usr/lib/x86_64-linux-gnu/
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/ version `Qt_5_PRIVATE_API' not found (required by /usr/lib/x86_64-linux-gnu/
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/ version `Qt_5' not found (required by /usr/lib/x86_64-linux-gnu/

I checked QT5’s packages for Core, GUI, OpenGL, SVG (also the dev versions with header files). Everything seems to be installed.

This is the config file:

# autogenerated by MRtrix configure script
# configure output:
# MRtrix build type requested: release version
# Detecting OS: linux
# Looking for compiler [clang++]: not found
# Looking for compiler [g++]: g++ (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
# 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.2.92
# Checking for zlib compression library: 1.2.8
# Checking for "JSON for Modern C++" requirements: ok
# Checking for TIFF library: LIBTIFF, Version 4.0.6
# Checking for FFTW library: fftw-3.3.4-sse2-avx
# Checking for Qt moc: moc (version 5.5.1)
# Checking for Qt qmake: qmake (version 5.5.1)
# Checking for Qt rcc: rcc (version 5.5.1)
# Checking for Qt: 5.5.1

PATH = r'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin'
obj_suffix = '.o'
exe_suffix = ''
lib_prefix = 'lib'
lib_suffix = '.so'
cpp = [ 'g++', '-c', 'CFLAGS', 'SRC', '-o', 'OBJECT' ]
cpp_flags = [ '-std=c++11', '-DMRTRIX_BUILD_TYPE="release version"', '-pthread', '-fPIC', '-I/usr/local/include/igtl', '-DMRTRIX_WORD64', '-DMRTRIX_TIFF_SUPPORT', '-isystem', '/usr/include/x86_64-linux-gnu', '-DEIGEN_FFTW_DEFAULT', '-Wall', '-O3', '-DNDEBUG' ]
ld = [ 'g++', 'OBJECTS', 'LDFLAGS', '-o', 'EXECUTABLE' ]
ld_flags = [ '-Wl,--sort-common,--as-needed', '-pthread', '-L/usr/local/lib/igtl', '-lOpenIGTLink', '-lz', '-ltiff', '-lfftw3' ]
runpath = '-Wl,-rpath,$ORIGIN/'
ld_enabled = True
ld_lib = [ 'g++', 'OBJECTS', 'LDLIB_FLAGS', '-o', 'LIB' ]
ld_lib_flags = [ '-shared', '-Wl,--sort-common,--as-needed', '-pthread', '-L/usr/local/lib/igtl', '-lOpenIGTLink', '-lz', '-ltiff', '-lfftw3' ]
eigen_cflags = [ '-isystem', '/usr/include/eigen3', '-DEIGEN_DONT_PARALLELIZE' ]
moc = 'moc'
rcc = 'rcc'
qt_cflags = [ '-m64', '-pipe', '-std=c++0x', '-Wall', '-W', '-D_REENTRANT', '-fPIC', '-DQT_NO_DEBUG', '-DQT_OPENGL_LIB', '-DQT_SVG_LIB', '-DQT_WIDGETS_LIB', '-DQT_GUI_LIB', '-DQT_CORE_LIB', '-isystem', '/usr/include/x86_64-linux-gnu/qt5', '-isystem', '/usr/include/x86_64-linux-gnu/qt5/QtOpenGL', '-isystem', '/usr/include/x86_64-linux-gnu/qt5/QtSvg', '-isystem', '/usr/include/x86_64-linux-gnu/qt5/QtWidgets', '-isystem', '/usr/include/x86_64-linux-gnu/qt5/QtGui', '-isystem', '/usr/include/x86_64-linux-gnu/qt5/QtCore', '-isystem', '/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64' ]
qt_ldflags = [ '-m64', '-Wl,-O1', '-L/usr/X11R6/lib64', '-lQt5OpenGL', '-lQt5Svg', '-lQt5Widgets', '-lQt5Gui', '-lQt5Core', '-lGL', '-lpthread' ]
nogui = False


OK, this is slightly complicated to get right. I’ll first try to explain how things (probably) work, and try to figure out what’s going on in your case as we go.

To compile an application using (a version of) Qt, there are a number of steps to get right:

  • The right versions of the Qt-specific qmake, moc and rcc executables need to be in the PATH. In other words, when you type qmake -v, you need to see the version you intended. At the moment, you’re getting the 5.11 version regardless.

  • Some parts of the code need to be processed by running moc on them (a Qt-specific quirk). If you’ve been running the wrong version, it’ll subsequently fail to compile the files generated by moc with the headers of a different version, giving the message you see on your first post.

  • The headers (include files) for the desired version have to be provided during the compile cycle (the settings for this are actually automatically figured out by the ./configure script by invoking qmake – hence the need to make sure the right version of that executable is available).

  • The library for the correct version has to be provided during the link cycle (the last stage of the build process, which produces the final executables). Again, this should be automatically figured out by the ./configure script, as per the previous step.

  • The library for the same correct version must be available at runtime. I’m guessing your last set of messages relate to a mismatch of that type. This is about making sure the runtime linker is properly configured, which is done differently (but we’d need to figure out what’s wrong first – see below).

So to fix your issues:

  • Why are you trying to use Qt4? Is it purely to get around the problems you’re describing with Qt5 in your second post? If so, I suggest we focus on fixing that.

  • Looking at your second post, it looks like the Qt5 build went as expected, but for some reason the right versions of the library can’t be found at runtime. This can happen since the mechanisms used to locate the libraries differ between the link stage (i.e. in the build) and runtime. You can probe which libraries the system is loading for your executable using the ldd command, e.g. on my system:

$ ldd bin/mrview (0x00007fff155ab000) => /home/jdt13/mrtrix3/bin/../lib/ (0x00007f611a236000) => /usr/lib/ (0x00007f6119b74000) => /usr/lib/ (0x00007f61195e3000) => /usr/lib/ (0x00007f61190e1000) => /usr/lib/ (0x00007f611904e000) => /usr/lib/ (0x00007f611902d000) => /usr/lib/ (0x00007f6118e9c000) => /usr/lib/ (0x00007f6118d17000) => /usr/lib/ (0x00007f6118cfd000) => /usr/lib/ (0x00007f6118b39000)
        /lib64/ => /usr/lib64/ (0x00007f611a82a000) => /usr/lib/ (0x00007f6118922000) => /usr/lib/ (0x00007f6118897000) => /usr/lib/ (0x00007f611885d000) => /usr/lib/ (0x00007f611877a000) => /usr/lib/ (0x00007f61186ee000) => /usr/lib/ (0x00007f6118410000) => /usr/lib/ (0x00007f6118240000) => /usr/lib/ (0x00007f61181c6000) => /usr/lib/ (0x00007f61181ad000) => /usr/lib/ (0x00007f61181a8000) => /usr/lib/ (0x00007f6118085000) => /usr/lib/ (0x00007f6118052000) => /usr/lib/ (0x00007f6117f13000) => /usr/lib/ (0x00007f6117d01000) => /usr/lib/ (0x00007f6117c43000) => /usr/lib/ (0x00007f6117bab000) => /usr/lib/ (0x00007f6117985000) => /usr/lib/ (0x00007f61178f0000) => /usr/lib/ (0x00007f6117627000) => /usr/lib/ (0x00007f6117600000) => /usr/lib/ (0x00007f61175f6000) => /usr/lib/ (0x00007f61175d7000) => /usr/lib/ (0x00007f61174b8000) => /usr/lib/ (0x00007f6115aca000) => /usr/lib/ (0x00007f6115856000) => /usr/lib/ (0x00007f611582c000) => /usr/lib/ (0x00007f6115819000) => /usr/lib/ (0x00007f61155f9000) => /usr/lib/ (0x00007f61153f5000) => /usr/lib/ (0x00007f61151ed000)

Have a close look at what exact file is being used for the line - there’s a good chance it won’t match the location, and give you a clue for why there is a mismatch. My guess: you’ve actually got another version of Qt installed somewhere via some other channel, and it’s conflicting with the version you’re building against. A prime suspect here is the Anaconda project – it has an uncanny knack for causing all sorts of issues of this type…

  • If there is some other reason why you need to use Qt4, then the simplest thing to do is to edit your PATH to ensure the location where the right versions of the Qt4 qmake, moc and rcc commands reside is listed first, to make sure these are the versions invoked. This will depend on where they’ve been installed. Given you seem to be running on Ubuntu, typing something like this might do the trick:
dpkg -L qt4-qmake 

This will most likely be /usr/lib/x86_64-linux-gnu/qt4/bin/, which you can add to your PATH before invoking ./configure using:

export PATH=/usr/lib/x86_64-linux-gnu/qt4/bin/:$PATH

Hope this helps you at least get started…