Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to reduce build time?



  • I have made a large project on Qt Creator. Qt is taking much time to build even if i change one line in .cpp file. What are the tips to reduce build time?

    I have made one common.h in which I have included all Widgets like #include <QPushButton>
    I am adding that common.h to my cpp files.



  • Hi,
    Some thoughts:

    1. use forward declaration
    2. include only what You do use
    3. enable PCH

    Main speed up comes from 1 and 3, on MSVC PCH do increase compilation time amazingly, on gcc and clang not so much (i.e. my large project on MSVC resulted in speed up from 3 min to 40sec ! while, same project, on Android and clang speed was around 15sec).

    PS. I do assume that You do use jom and on clang and gcc -j flags to enable multi threaded support. If not then:
    msvc -> jom or use, IIRC, /N <Your CPU supported thread count> + 1 i.e. /N 9 for quad core
    clang / gcc -> -j 9
    This is added in project make arguments as above


  • Qt Champions 2017

    @mit_cruze said in How to reduce build time?:

    I have made one common.h in which I have included all Widgets like #include <QPushButton>

    Don't do that and build time will improve. Additionally, use templates sparingly and if you do, manually instantiate them.


Log in to reply