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

Cross compilation, pkg-config issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.9.0
    • None
    • Up-to-date Arch Linux
      ptxdist 2017.06.0
      OSELAS 2016.06.1

       

    Description

      I am trying to cross compile Qt-5.9 for an ARM target using the latest ptxdist (2017.06.0) and OSELAS toolchain (2016.06.1).

      The problem I encounter is related to Qt requiring the environment variable PKG_CONFIG_SYSROOT_DIR which is somewhat not a good idea:
      In my understanding, this variable is owned by pkg-config itself. Since the qt-configuration requires it and exports it at the same time.

      1) when trying to configure Qt without -pkg-config, as one would expect, it will not pass the config-tests for dbus and a bunch of other libraries, due to not finding the corresponding headers.

      2) when trying to configure Qt with -pkg-config, the configuration is disabling pkg-config again, thus not passing config-tests. The reason is printed by configure as follows:

      WARNING: Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set.
      Set this variable to your sysroot for pkg-config to function correctly when
      cross-compiling or use -pkg-config to override this test.
      

      3) when trying to configure Qt with -pkg-config and supplying the environment variable PKG_CONFIG_SYSROOT_DIR accordingly, the config-test for dbus (unexpectedly) still fails.

      After some research, I could locate the problem to the call of pkg-config, excerpt from config.log (shortened to the relevant bits):

      pkg-config --cflags dbus-1 '>=' 1.2
      > -I/home/<lengthy-path-to-sysroot>/home/<lengthy-path-to-sysroot>/usr/include/dbus-1.0 -I/home/<lengthy-path-to-sysroot>/home/<lengthy-path-to-sysroot>/usr/lib/dbus-1.0/include 
      

      Apparently pkg-config prepends the actual include path once again with the path to the SYSROOT, picked up from PKG_CONFIG_SYSROOT_DIR. pkg-config(1) reveals the reason for that:

             PKG_CONFIG_SYSROOT_DIR
                    Modify  -I and -L to use the directories located in target sysroot.  this option is useful when cross-compiling packages that use pkg-config to determine CFLAGS and LDFLAGS. -I and -L are modi‐
                    fied to point to the new system root. this means that a -I/usr/include/libfoo will become -I/var/target/usr/include/libfoo with a PKG_CONFIG_SYSROOT_DIR equal to /var/target (same rule apply to
                    -L)
      

      As a solution to that, the Qt configuration should either:
      1) Not require pkg-configs variables to be configured
      2) Require them but not export them.

      As a workaround, I decided to choose 1), which I absolutely consider a workaround, not a proper fix (see attached patch).

      On the other hand, I can hardly believe that I am the first one running into this issue with cross-compilation, so if I made blatantly wrong assumptions about how to cross-compile Qt5.9 I'd be glad to be enlightened.

      Attachments

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

        Activity

          People

            buddenha Oswald Buddenhagen
            f.baeuerle Florian Bäuerle
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes