Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Optimize compile time
Qt 6.12 LTS is out! See what's new in the release blog

Optimize compile time

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 724 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CesarC Offline
    CesarC Offline
    Cesar
    wrote on last edited by
    #1

    I'm compiling my project just to Windows os, i compiling under Visual Studio 2022, i wonder if there's any option or settings, etc
    in which could help reduce compiling time?

    I'm already using pre-compiled header, is it 'ok' to add qt includes like: #include <QtWidgets/QMainWindow> into the pch?

    Chris KawaC 1 Reply Last reply
    0
    • CesarC Cesar

      I'm compiling my project just to Windows os, i compiling under Visual Studio 2022, i wonder if there's any option or settings, etc
      in which could help reduce compiling time?

      I'm already using pre-compiled header, is it 'ok' to add qt includes like: #include <QtWidgets/QMainWindow> into the pch?

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      i wonder if there's any option or settings, etc in which could help reduce compiling time?

      A couple, yes, but first you have to know what the problem actually is. Flipping switches at random won't get you far.

      is it 'ok' to add qt includes like: #include <QtWidgets/QMainWindow> into the pch?

      In general yes, but keep in mind that this might not get you the effect you're after if you put there too much. Precompiled headers are not magic. Compilation time of the pch itself might increase dramatically and keep in mind that the resulting object file is kinda sticked in front of every other compiled file, so big pch's can increase linking time.

      I would start by refactoring includes - make sure you don't put includes in headers unless you absolutely need to. Use forward declarations as much as possible. Analyze your dependencies, especially the transitional ones, so you don't include the same files multiple times. If you use a lot of templates or constexpr see if you can reduce their use or include only where really needed etc.

      Since you're using VS2022 there's a nice extension called CompileScore that can help you with pinpointing compilation hotspots and bottlenecks. It lets you dig deep into compilation times to see what actually takes time. It even colors your includes so you can see which of them are the heaviest and need attention.

      1 Reply Last reply
      5

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved