Qt World Summit: Register Today!

qmake.conf: How to append CFLAGS/LFLAGS to the tail of flags

  • In qmake.conf, if I add:

    The actual link flags will become: (when building Gui)
    g++ -L{MY_SYSROOT} ... -Wl,-soname,libQt5Gui.so.5 -o ... -L{MY_BUILD_DIR}/lib -lQt5Core ...

    SYSROOT is searched before local build directory, which is definitely problematic.
    (Because if Core changed source or config, Qt5Gui may break build unless Qt5 is uninstalled from sysroot.)

    How to append flags to the tail of flags?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Something's not clear from your description, what are you building currently ?

  • @SGaist
    Sorry for the slow reply.
    I am building whole qt5 for an embedded linux.
    In qmake.conf, I used QMAKE_LFLAGS to add SYSROOT to link flags.

    The problem is that in generated makefiles' link flags, SYSROOT is searched before local build directory.
    (IOW QMAKE_LFLAGS is injected before other lflags, which is problematic)
    This link order is obviously wrong, and rebuild often breaks due to it.

    Unstalling qt5 from SYSROOT at rebuild is unacceptable, because in our project build system, it is not allowed to touch SYSROOT at build/clean stage.

  • @myobyte said:


    I guess the key to your problem is using += instead of just = so the new value is APPENDED to the existing value of the variable


  • Lifetime Qt Champion

    You can pass the sysroot option to configure, doesn't that work for you ?

  • @SGaist
    Thanks, it worked.
    However, a similar problem is still there: how to append a "BuildRoot" aka "TargetFsRoot" to include/link search path, for various non-toolchain libraries?

  • Lifetime Qt Champion

    Do you mean something like configure -I /path/to/my/includes ?

  • @SGaist
    If I add -I -L -R to configure, host tools build fails because it is also affected:

    g++ -Wl,-O1 -Wl,-rpath,arm/target/rootfs/usr/lib -Wl,-rpath,arm/target/rootfs/usr/lib -o ../../../bin/qdoc .obj/... 
    -Larm/target/rootfs/usr/lib -Lsrc/qtbase/build/lib -lQt5Bootstrap -lpthread

    Also it looks bad:
    L_FLAGS appears before -Lsrc/qtbase/build/lib -lQt5Bootstrap -lpthread

  • Lifetime Qt Champion

    Since you can not modify the sysroot. Why not just use another one when building Qt and put the final result in the original after that ?

Log in to reply