Important: Please read the Qt Code of Conduct -

Missing flags when cross-compiling my QT app

  • Hello there,

    I'm cross-compiling QT5.4 using ptxdist. It worked well until I tried to compile my own QT application. I have linker errors: undefined reference to dbus_message_get_interface' undefined reference tog_main_context_push_thread_default'

    However, if I add the LDFLAGS manually (-ldbus-1 -lglib-2.0 -lz) it works fine but that's quiet annoying, I was expecting that QT could provide those flags itself!

    Here is my mkspecs:

    qmake configuration for linux-ptx-g++


    TEMPLATE = app
    CONFIG += qt warn_on release incremental link_prl
    QT += core gui network

    modifications to g++.conf

    QMAKE_CC = arm-1136jfs-linux-gnueabihf-gcc
    QMAKE_CFLAGS = -pipe
    QMAKE_CXX = arm-1136jfs-linux-gnueabihf-g++
    QMAKE_CXXFLAGS = -pipe
    QMAKE_INCDIR = /home/admin/bsp/platform-ifc/sysroot-target/include /home/admin/bsp/platform-ifc/sysroot-target/usr/include
    QMAKE_LIBDIR = /home/admin/bsp/platform-ifc/sysroot-target/lib /home/admin/bsp/platform-ifc/sysroot-target/usr/lib

    QMAKE_LINK = arm-1136jfs-linux-gnueabihf-g++
    QMAKE_LINK_SHLIB = arm-1136jfs-linux-gnueabihf-g++


    modifications to linux.conf

    QMAKE_AR = arm-1136jfs-linux-gnueabihf-ar cqs
    QMAKE_OBJCOPY = arm-1136jfs-linux-gnueabihf-objcopy
    QMAKE_STRIP = arm-1136jfs-linux-gnueabihf-strip

    Are those missing flags supposed to be defined in the mkspecs I provide? How can I add or remove flags in the mkspecs depending on QT5 configuration (-dbus vs -dbus-link vs -no-dbus)? Should I include another mkspecs from QT? What am I missing?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you show your application pro file ?

  • Thanks! I wish I could contribute more often but most of the time the answer to my question is already somewhere in the Forum :)

    Here is the most relevant part of my .pro file:
    @QT += core dbus
    QT -= gui

    To handle gpio changes using local socket on pc

    QT += network

    TARGET = io-svc
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += ...

    HEADERS += ...

    linux-g++ {
    message(Building on HOST machine)

    linux-ptx-g++ {
    message(Building on IFC)
    LIBS += -lsystemd-journal -llzma

    # FIXME: We shouldn't need to specify those flags, those are depedencies from QTDbus and QTCore
    LIBS += -ldbus-1 -lglib-2.0 -lz


    win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../ifc-lib/release/ -lifc
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../ifc-lib/debug/ -lifc
    else:symbian: LIBS += -lifc
    else:unix: LIBS += -L$$OUT_PWD/../ifc-lib/ -lifc

    INCLUDEPATH += $$PWD/../ifc-lib
    DEPENDPATH += $$PWD/../ifc-lib@

  • Lifetime Qt Champion

    What is linux-ptx-g++ ?

  • linux-ptx-g++ is my mkspec file coming from the ptxdist toolchain.

  • Lifetime Qt Champion

    Does it do any unusual variable assignment ?

  • Its content is shown on the first post. I don't think it does any "unusual" variable assignement but maybe there is something missing ... ??

    Thanks for pointing this out!

  • Lifetime Qt Champion

    What option did you use when cross-compiling Qt ?

  • It's difficult to say, QT is built by ptxdist and there are potentially many. Here is the flags from the ptxdist build instruction:
    @ $(if $(filter 1,$(PTXDIST_VERBOSE)),-v)
    $(if $(filter 0,$(PTXDIST_VERBOSE)),-silent)
    -prefix /usr
    -headerdir /usr/include/qt5
    -archdatadir /usr/lib/qt5
    -datadir /usr/share/qt5
    -examplesdir /usr/lib/qt5/examples
    -hostbindir /usr/bin/qt5
    -xplatform linux-ptx-g++
    --$(call ptx/endis, PTXCONF_QT5_CXX11)-c++11
    --$(call ptx/endis, PTXCONF_GLOBAL_LARGE_FILE)-largefile
    --$(call ptx/endis, PTXCONF_QT5_ACCESSIBILITY)-accessibility
    --$(call ptx/endis, PTXCONF_QT5_MODULE_QTBASE_SQL_SQLITE)-sql-sqlite
    --$(call ptx/endis, PTXCONF_QT5_MODULE_QTDECLARATIVE_DEBUG)-qml-debug

    $(call ptx/ifdef, PTXCONF_QT5_GIF,,-no-gif)
    $(call ptx/qt5-system, QT5_LIBPNG)-libpng
    $(call ptx/qt5-system, QT5_LIBJPEG)-libjpeg
    $(call ptx/qt5-system, QT5_GUI)-freetype
    --$(call ptx/endis, PTXCONF_QT5_OPENSSL)-openssl

    -make libs
    -make tools
    $(call ptx/ifdef, PTXCONF_QT5_PREPARE_EXAMPLES,-make examples)
    -skip qtactiveqt
    -skip qtandroidextras
    $(call ptx/qt5-module, QTCONNECTIVITY, qtconnectivity)
    $(call ptx/qt5-module, QTDECLARATIVE, qtdeclarative)
    $(call ptx/qt5-module, QTENGINIO, qtenginio)
    -skip qtdoc
    $(call ptx/qt5-module, QTGRAPHICALEFFECTS, qtgraphicaleffects)
    $(call ptx/qt5-module, QTIMAGEFORMATS, qtimageformats)
    $(call ptx/qt5-module, QTLOCATION, qtlocation)
    -skip qtmacextras
    $(call ptx/qt5-module, QTMULTIMEDIA, qtmultimedia)
    $(call ptx/qt5-module, QTQUICK1, qtquick1)
    $(call ptx/qt5-module, QTQUICKCONTROLS, qtquickcontrols)
    $(call ptx/qt5-module, QTSCRIPT, qtscript)
    $(call ptx/qt5-module, QTSENSORS, qtsensors)
    $(call ptx/qt5-module, QTSERIALPORT, qtserialport)
    $(call ptx/qt5-module, QTSVG, qtsvg)
    $(call ptx/qt5-module, QTTOOLS, qttools)
    $(call ptx/qt5-module, QTTRANSLATIONS, qttranslations)
    $(call ptx/qt5-module, QTWAYLAND, qtwayland)
    $(call ptx/qt5-module, QTWEBCHANNEL, qtwebchannel)
    $(call ptx/qt5-module, QTWEBENGINE, qtwebengine)
    $(call ptx/qt5-module, QTWEBKIT, qtwebkit)
    $(call ptx/qt5-module, QTWEBKIT_EXAMPLES, qtwebkit-examples)
    $(call ptx/qt5-module, QTWEBSOCKETS, qtwebsockets)
    -skip qtwinextras
    $(call ptx/qt5-module, QTX11EXTRAS, qtx11extras)
    $(call ptx/qt5-module, QTXMLPATTERNS, qtxmlpatterns)
    --$(call ptx/endis, PTXCONF_QT5_PREPARE_EXAMPLES)-compile-examples
    --$(call ptx/endis, PTXCONF_QT5_GUI)-gui
    --$(call ptx/endis, PTXCONF_QT5_WIDGETS)-widgets
    --$(call ptx/endis, PTXCONF_QT5_ICU)-icu
    --$(call ptx/endis, PTXCONF_QT5_GUI)-fontconfig
    --$(call ptx/endis, PTXCONF_QT5_DBUS)-dbus$(call ptx/ifdef, PTXCONF_QT5_DBUS,-linked,)
    --$(call ptx/endis, PTXCONF_QT5_PLATFORM_XCB)-xcb
    --$(call ptx/endis, PTXCONF_QT5_PLATFORM_EGLFS)-eglfs
    --$(call ptx/endis, PTXCONF_QT5_PLATFORM_DIRECTFB)-directfb
    --$(call ptx/endis, PTXCONF_QT5_PLATFORM_LINUXFB)-linuxfb
    --$(call ptx/endis, PTXCONF_QT5_PLATFORM_KMS)-kms
    $(call ptx/ifdef, PTXCONF_QT5_GUI,-qpa $(PTXCONF_QT5_PLATFORM_DEFAULT))
    --opengl=$(call ptx/ifdef, PTXCONF_QT5_OPENGL,$(PTXCONF_QT5_OPENGL_API),no)
    --$(call ptx/endis, PTXCONF_QT5_GLIB)-glib
    Is there any flag I should be more carfull?

  • mmm ....I've just noticed that the -sysroot flag is not set, can it be this? There only one way to know it :-p!

Log in to reply