Tips for faster compilation on QtCreator?


I’m wondering if there are any flags we can set in QtCreator to improve compilation time? Like the -j flag in make to make it multithreaded?
Does ccache help? I’ve read that sometimes it does, other times it doesn’t. If it does, how to make QtCreator use it?
Are there any flag to do less optimizations (and compile faster) while developing?

Or is everything configured right by default? :slight_smile:

Anyone tried zapcc?

qtcreator already uses all available cores for compiling, same as using -j. the only difference is that if you make changes to OF itself, since OF is still compiled using makefiles it’s always compiled using -j4.

Also the debug target has no optimizations so is as fast as it gets.

ccache or similar tools are useful when you have to clean your project and build from scratch really often but usually using qtcreator or the default OF makefiles it’ll only compile files that have changed so it shouldn’t make a big difference.

Something to take into account is that a file is considered as changed also when a header that it includes (recursively) changes so reducing the number of includes as much as possible and including as few things as possible in .h to instead put them in cpp can speed things up when compiling

Thank you for all the details!

I just came up with one more idea: set the build folder to be on a ram disk. At least in ArchLinux, /tmp is by default a ram drive, so I just set the default build folder to /tmp/build-%{CurrentProject:Name}-%{CurrentBuild:Name}. I also had to change it in the qbs.user file for existing projects. I didn’t benchmark it, but it feels faster.

1 Like