Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Project compilation very very slow with boost
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Project compilation very very slow with boost

Scheduled Pinned Locked Moved General and Desktop
9 Posts 6 Posters 12.1k 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.
  • L Offline
    L Offline
    lloydqt
    wrote on last edited by
    #1

    Hi,

    I am using Qt 4.8.1 along with boost libraries (especially boost::asio), on Windows 7 with Visual Studio 2010. It takes little more time to compile boost based programs, but it is acceptable. But when I mix Qt and boost the "moc" process as well as the compilation of each file (the files which are independent of boost also)takes lot of time. Does anybody have experienced this? What could be the reason? How can it be solved?

    The compilation time really affects our productivity.

    Thanks,
    Lloyd

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Try running one of those slow files through the C preprocessor and check how big the output is. My guess is that you are dragging in (almost) all of Qt and boost at the same time. Having a couple of lines turn into a >100k line monster does happen and the compiler will have to munch through all that data.

      Try to reduce the amount of includes, use forward declarations whenever possible, etc. You might also be able to use precompiled headers to speed this up.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        Try especially to avoid including Boost headers in your header files, preferring to include them only in the implementation files. The private implementation method can help here. If you must include Boost headers in other header files make sure you use the forward declaration headers (i.e. *_fwd.h) if at all possible, and the bare minimum specific Boost includes otherwise.

        Asio is header-only, so there is a quite a lot of implementation code to build for every single file that includes it. You could also try using the "Optional separate compilation":http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/using.html mechanism.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lloydqt
          wrote on last edited by
          #4

          Thanks a lot. As a first attempt I went with precompiled headers and it has improved very much. To improve it further I shall try including the "*_fwd.h" headers.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            You should always try to include as less as possible in headers.
            A common way is to use forward declarations for all things that are needed and only include the headers for member variables, if they are no pointers. This speeds up building a lot. Pre compiled headers also have a big disadvantage:

            You perhaps need to include them in the header (or it is not usable in cpp files if they do not want to include the pre compiled header or come from a different binary artifact). And if you add a header, you have to recompile the whole thing and not only one cpp.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lloydqt
              wrote on last edited by
              #6

              Thats an important point. As a quick fix I opted the precompiled header option. I will be moving to forward headers as soon as possible. I am using only very minimal headers in my header files.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Raay221
                wrote on last edited by
                #7

                Here we are using "Incredibuild":http://www.incredibuild.com , which distribute the build process all over our machines. Builds that went on for 3 hours are now taking less than 20 minutes. You should definitely take a look and see if it suites you!

                1 Reply Last reply
                0
                • jensen82J Offline
                  jensen82J Offline
                  jensen82
                  wrote on last edited by
                  #8

                  Which boost-libs are you using? If you're using spirit and do some parsing it will take a long time beacause of meta-template-programming,

                  1 Reply Last reply
                  0
                  • jensen82J Offline
                    jensen82J Offline
                    jensen82
                    wrote on last edited by
                    #9

                    Solved? What was the problem? Please tell. So everybody can benefit from your experience.

                    1 Reply Last reply
                    0

                    • Login

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