Installing with QT 4 on a machine with multiple QT installations

installation

#1

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
Darius


#3

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/libQt5Core.so.5: version `Qt_5_PRIVATE_API' not found (required by /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5)
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.9' not found (required by /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5)
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5' not found (required by /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5)
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5_PRIVATE_API' not found (required by /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5)
bin/mrview-igtlink: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5' not found (required by /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5)

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:

#!/usr/bin/python
#
# 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

@Lucius


#4

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
        linux-vdso.so.1 (0x00007fff155ab000)
        libmrtrix.so => /home/jdt13/mrtrix3/bin/../lib/libmrtrix.so (0x00007f611a236000)
        libQt5Widgets.so.5 => /usr/lib/libQt5Widgets.so.5 (0x00007f6119b74000)
        libQt5Gui.so.5 => /usr/lib/libQt5Gui.so.5 (0x00007f61195e3000)
        libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x00007f61190e1000)
        libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f611904e000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f611902d000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f6118e9c000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007f6118d17000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f6118cfd000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f6118b39000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f611a82a000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007f6118922000)
        libtiff.so.5 => /usr/lib/libtiff.so.5 (0x00007f6118897000)
        libpng16.so.16 => /usr/lib/libpng16.so.16 (0x00007f611885d000)
        libharfbuzz.so.0 => /usr/lib/libharfbuzz.so.0 (0x00007f611877a000)
        libsystemd.so.0 => /usr/lib/libsystemd.so.0 (0x00007f61186ee000)
        libicui18n.so.63 => /usr/lib/libicui18n.so.63 (0x00007f6118410000)
        libicuuc.so.63 => /usr/lib/libicuuc.so.63 (0x00007f6118240000)
        libpcre2-16.so.0 => /usr/lib/libpcre2-16.so.0 (0x00007f61181c6000)
        libdouble-conversion.so.3.0.0 => /usr/lib/libdouble-conversion.so.3.0.0 (0x00007f61181ad000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f61181a8000)
        libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f6118085000)
        libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007f6118052000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f6117f13000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f6117d01000)
        libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007f6117c43000)
        libzstd.so.1 => /usr/lib/libzstd.so.1 (0x00007f6117bab000)
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f6117985000)
        libjpeg.so.8 => /usr/lib/libjpeg.so.8 (0x00007f61178f0000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007f6117627000)
        libgraphite2.so.3 => /usr/lib/libgraphite2.so.3 (0x00007f6117600000)
        librt.so.1 => /usr/lib/librt.so.1 (0x00007f61175f6000)
        liblz4.so.1 => /usr/lib/liblz4.so.1 (0x00007f61175d7000)
        libgcrypt.so.20 => /usr/lib/libgcrypt.so.20 (0x00007f61174b8000)
        libicudata.so.63 => /usr/lib/libicudata.so.63 (0x00007f6115aca000)
        libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f6115856000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f611582c000)
        libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f6115819000)
        libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x00007f61155f9000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f61153f5000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f61151ed000)

Have a close look at what exact file is being used for the libQtCore.so.5 line - there’s a good chance it won’t match the libQt5Widgets.so.5 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
./configure

Hope this helps you at least get started…