ERROR: error compiling Qt application!

Here is part of my configuration file. I’m not sure why this is happening

 export LD_LIBRARY_PATH=/usr/local/qt-5.6.2/5.6/gcc_64/lib:/usr/local/gcc-4.9.4/lib/../lib64:/usr/local/mpc-1.0.2/lib/:/usr/local/mpfr-3         .1.5/lib/:/usr/local/gmp-6.1.2/lib/:$LD_LIBRARY_PATH
(base) [root@c2004 ylu]# export PATH=/usr/local/qt-5.6.2/5.6/gcc_64/bin/:$PATH
(base) [root@c2004 ylu]# cd /usr/local/mrtrix3
(base) [root@c2004 mrtrix3]# CXX=/usr/local/gcc-4.9.4/bin/g++ ./configure



int main() { Foo f; }
---

project file "qt.pro":
---
CONFIG += c++11
QT += core gui opengl svg
HEADERS += qt.h
SOURCES += qt.cpp
---
EXEC <<
CMD: qmake
EXIT: 0
>>

EXEC <<
CMD: moc qt.h -o qt_moc.cpp
EXIT: 0
>>

EXEC <<
CMD: /usr/local/gcc-4.9.4/bin/g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -DMRTRIX_TIFF_SUPPORT -DEIGEN_FFTW_DEFAULT -pipe -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/include -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/include/QtOpenGL -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/include/QtSvg -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/include/QtWidgets -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/include/QtGui -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore -idirafter /usr/local/qt-5.6.2/5.6/gcc_64/mkspecs/linux-g++ qt.cpp -o qt.o
EXIT: 1
STDERR:
In file included from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/QObject:1:0,
                 from qt.h:1,
                 from qt.cpp:2:
from qt.h:1,
                 from qt.cpp:2:
/usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject.h:493:24: error: missing binary operator before token "("
 #if QT_DEPRECATED_SINCE(5, 0)
                        ^
In file included from /usr/include/QtCore/qdatastream.h:46:0,
                 from /usr/include/QtCore/qmetatype.h:49,
                 from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject.h:48,
                 from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/QObject:1,
                 from qt.h:1,
                 from qt.cpp:2:
/usr/include/QtCore/qiodevice.h:68:14: error: invalid use of incomplete type ‘class QObject’
     : public QObject
              ^
In file included from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject.h:40:0,
                 from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/QObject:1,
                 from qt.h:1,
                 from qt.cpp:2:
/usr/include/QtCore/qobjectdefs.h:238:7: error: forward declaration of ‘class QObject’
 class QObject;
       ^
In file included from /usr/include/QtCore/qnamespace.h:45:0,
                 from /usr/include/QtCore/qobjectdefs.h:45,
                 from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject.h:40,
                 from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/QObject:1,
                 from qt.h:1,
                 from qt.cpp:2:
/usr/include/QtCore/qiodevice.h: In member function ‘QIODevicePrivate* QIODevice::d_func()’:
/usr/include/QtCore/qiodevice.h:168:5: error: ‘d_ptr’ was not declared in this scope
     Q_DECLARE_PRIVATE(QIODevice)
     ^
/usr/include/QtCore/qiodevice.h: In member function ‘const QIODevicePrivate* QIODevice::d_func() const’:
/usr/include/QtCore/qiodevice.h:168:5: error: ‘d_ptr’ was not declared in this scope
     Q_DECLARE_PRIVATE(QIODevice)
     ^
In file included from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject.h:50:0,
                 from /usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/QObject:1,
                 from qt.h:1,
                 from qt.cpp:2:
/usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject_impl.h: At global scope:
/usr/local/qt-5.6.2/5.6/gcc_64/include/QtCore/qobject_impl.h:62:76: error: ‘List’ was not declared in this scope
     template <typename Arg, typename Tail> struct TypesAreDeclaredMetaType<List<Arg, Tail> > { enum { Value = QMetaTypeId2<Arg>::Defined && TypesAreDeclaredMetaType<Tail>::Value }; };

You’re trying to use your own, non-default version of Qt 5.6 installed in /usr/local/qt-5.6.2/, but it conflicts with your system version of Qt installed in /usr/include. Unfortunately whatever Linux distribution you’re using has decided to place the development files for their version of Qt in a location where they can’t be ignored, making it essentially impossible to use your version instead of yours (this is very poor packaging from them, what version of Linux are you using?).

The only way I can think of to avoid this is to remove the development files for your system version of Qt. This is probably as simple as removing the qt-devel package – although the exact name of that package and the command you would use to do this will depend on the specifics of your Linux distribution and the particular package manager it uses. You can always re-install it later once MRtrix3 is compiled. If you’re struggling with this, we should be able to figure it out if you tell us exactly what version of Linux you’re running. Note this will require admin (root) access – which I note you already have.

The other (much simpler, in my opinion) way to fix this is to not use your own version of Qt, but rely on the system-supplied one. That should just be a matter of leaving the PATH variable alone. But I expect you have your reasons, given you’re also using your own compiler…?

1 Like