Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59457

hard-coded -rpath-link in mkspecs breaks builds with pre-installed qt

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.9.1
    • 5.8.0
    • Build System
    • None
    • Raspbian 8 / Raspberry Pi 3.
    • 5afde92bd76421a49b9eb76e6071b32fd3ca41df

    Description

      Since some months Raspian brings its own version of Qt (5.3?) which leads to linking errors when building Qt on the RasPi: Programs that depend on Qt module A where A depends on module B (but the program does not directly depend on) can't be linked because the linker tries to resolve B using the (outdated) system libraries.

      For example canbustool depends on libQtSerialBus which depends on libQtNetwork (but the cantool does not directly depend on it):

      linking ../../../bin/canbusutil
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::newConnection()@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::QTcpServer(QObject*)@Qt_5'
      //usr/lib/arm-linux-gnueabihf/libQt5Network.so.5: undefined reference to `qt_safe_select(int, fd_set*, fd_set*, fd_set*, timespec const*)'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::acceptError(QAbstractSocket::SocketError
      )@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::close()@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QHostAddress::~QHostAddress()@Qt_5'
      //usr/lib/arm-linux-gnueabihf/libQt5Network.so.5: undefined reference to `qIsEffectiveTLD(QString const&)'
      //usr/lib/arm-linux-gnueabihf/libQt5Network.so.5: undefined reference to `QNonContiguousByteDevice::disableReset()'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::connected()@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::peerName() const@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::state() const@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::staticMetaObject@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::error(QAbstractSocket::SocketError)
      @Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::isListening() const@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::peerAddress() const@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::disconnected()@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::errorString() const@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpSocket::QTcpSocket(QObject*)@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QHostAddress::QHostAddress(QString const&)@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QAbstractSocket::peerPort() const@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::staticMetaObject@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `QTcpServer::listen(QHostAddress const&, unsigned sho
      rt)@Qt_5'
      /media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/lib/libQt5SerialBus.so: undefined reference to `operator<<(QDebug, QHostAddress const&)@Qt_5'
      collect2: error: ld returned 1 exit status
      Makefile:90: recipe for target '../../../bin/canbusutil' failed
      make[4]: *** [../../../bin/canbusutil] Error 1
      make[4]: Leaving directory '/media/pi/7018255e-fde8-46e9-9353-916727a36a5c/rpi3/src/qt-everywhere-opensource-src-5.8.0/qtserialbus/src/tools/canbusutil'
      Makefile:42: recipe for target 'sub-canbusutil-make_first' failed
      make[3]: *** [sub-canbusutil-make_first] Error 2
      

      I saw this problem the first time with Qt 5.8.0 but I think also previous versions are affected (especially 5.6.x LTS) since the problem came in with the Raspbian provided Qt version.

      In my case I was able to solve the problem by dropping the system library path from the file /qtbase/mkspecs/devices/common/linux_device_post.conf:

      #contains(DISTRO_OPTS, deb-multi-arch) {
      #    QMAKE_LFLAGS   += -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP} \
      #                      -Wl,-rpath-link,$$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP}
      #}
      

      This definition makes the system path appear in first place so the linker finds the wrong Qt libraries and ignores the following build path with the correct libraries.

      (A short workaround could be to tell the linker to ignore indirectly used libraries by setting QMAKE_LFLAGS="-Wl,-unresolved-symbols=ignore-in-shared-libs").

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              buddenha Oswald Buddenhagen
              mic Michael Hanfland
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes