Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Compile- and Linking Time Tips

Compile- and Linking Time Tips

Scheduled Pinned Locked Moved C / C++ / MFC
c++asp-nettutorialquestioncode-review
8 Posts 5 Posters 0 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.
  • I Offline
    I Offline
    InOut NET
    wrote on last edited by
    #1

    My application takes longer and longer to compile and run. I program in C++ Builder 2006. Each time I change something in my apps' Core bpl, it takes about 5 minuets to compile and up to 2 minuets to link. I waste about 1 hour a day waiting for my code to compile! Anybody have some pointers on how to optimize this kak process? Is it my header hierarchy or what influences the compiling and linking? -besides the lines of code. Thanks

    D R M S 4 Replies Last reply
    0
    • I InOut NET

      My application takes longer and longer to compile and run. I program in C++ Builder 2006. Each time I change something in my apps' Core bpl, it takes about 5 minuets to compile and up to 2 minuets to link. I waste about 1 hour a day waiting for my code to compile! Anybody have some pointers on how to optimize this kak process? Is it my header hierarchy or what influences the compiling and linking? -besides the lines of code. Thanks

      D Offline
      D Offline
      DevMentor org
      wrote on last edited by
      #2

      The only thing I can think of is that it's your header file inclusion, each time you change the definition in a header file all the source files that include it will get reprocessed, and depending on your compiler multiple inclusion of header files from different sources indirectly will only increase the preprocessing time. Only include the header files in the source that actually need them! Also do NOT have your header file include other header files, sometime you can't get away from this but most of the time developer are plain freaking lazy and will shover all kind of crap they don't need, or they have a global header file that includes other header, etc. The other thing you could do is separate your code and make it more modular and isolate functions, API, etc. Then you only have to rebuild (hopefully) that one module and link with it everywhere else saving time? Last solution, and the best!!!! Don't make changes to the code and then you don't need to worry about them pesky compiler problem!!! :laugh: 5 min + 2 min is nothing to complain about man!!! Some projects I know have taken much much longer to build :omg:

      1 Reply Last reply
      0
      • I InOut NET

        My application takes longer and longer to compile and run. I program in C++ Builder 2006. Each time I change something in my apps' Core bpl, it takes about 5 minuets to compile and up to 2 minuets to link. I waste about 1 hour a day waiting for my code to compile! Anybody have some pointers on how to optimize this kak process? Is it my header hierarchy or what influences the compiling and linking? -besides the lines of code. Thanks

        R Offline
        R Offline
        Rick York
        wrote on last edited by
        #3

        It could be something in your header file hierarchy. Is a pre-compiled header option available with Builder ? One thing I am now in the habit of doing (and I get some flak for) is a more proactive form of header inclusion guards. I use an included definition of the form :

        #ifndef _INCLUDEFILE_H
        #define _INCLUDEFILE_H
        ...

        then I also put this in comments for easy cutting and pasting :

        /***
        #ifndef _INCLUDEFILE_H
        #include "IncludeFile.h"
        #endif
        ***/

        and I use this form whenever I place an include statement in a header whether I am including one of mine or one from the compiler. Always ! Also - I usually take this even a bit farther. I make it a fatal error if a file is repeatedly included and this helps track them down quicker. This is done as follows :

        #ifndef _INCLUDEFILE_H
        #define _INCLUDEFILE_H
        #else
        #error repeated include of this file
        #endif

        You can comment off the #else and the #error if you don't want that to be a fatal error. In the past I have made the conversion to this style very quickly because it's easy to do and it has always resulted in significant improvements in compile time for me. In fact, generally speaking, the larger the project the larger the speed-up that I have seen. Now, this is only a compile time improvement so it does not address your link time issue. There are lots of variables involved in link time. Efficiency of the linker, amount of available memory, and hard drive speed are three biggies. Unfortunately I don't have any easy answers for this.

        I 1 Reply Last reply
        0
        • I InOut NET

          My application takes longer and longer to compile and run. I program in C++ Builder 2006. Each time I change something in my apps' Core bpl, it takes about 5 minuets to compile and up to 2 minuets to link. I waste about 1 hour a day waiting for my code to compile! Anybody have some pointers on how to optimize this kak process? Is it my header hierarchy or what influences the compiling and linking? -besides the lines of code. Thanks

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Also... You aren't doing full builds every time, are you? :) Mark

          Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

          I 1 Reply Last reply
          0
          • I InOut NET

            My application takes longer and longer to compile and run. I program in C++ Builder 2006. Each time I change something in my apps' Core bpl, it takes about 5 minuets to compile and up to 2 minuets to link. I waste about 1 hour a day waiting for my code to compile! Anybody have some pointers on how to optimize this kak process? Is it my header hierarchy or what influences the compiling and linking? -besides the lines of code. Thanks

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            Things to look into: 1. Precompiled headers. 2. Unneeded include files. 3. Using abstract base classes as interfaces to avoid having to include class definitions.

            Steve

            I 1 Reply Last reply
            0
            • M Mark Salsbery

              Also... You aren't doing full builds every time, are you? :) Mark

              Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

              I Offline
              I Offline
              InOut NET
              wrote on last edited by
              #6

              Yeah, I'm working in my Core at this time. It has alot of different helper forms, -casses and automation functions. I have to recompile the whole shabang, even if I only added a ShowMessage for debugging - The Builder Debugger crashes alot during step-trough variable inspection and i've lost tooo many code. (thanks to Builders bugs.:mad:)

              1 Reply Last reply
              0
              • R Rick York

                It could be something in your header file hierarchy. Is a pre-compiled header option available with Builder ? One thing I am now in the habit of doing (and I get some flak for) is a more proactive form of header inclusion guards. I use an included definition of the form :

                #ifndef _INCLUDEFILE_H
                #define _INCLUDEFILE_H
                ...

                then I also put this in comments for easy cutting and pasting :

                /***
                #ifndef _INCLUDEFILE_H
                #include "IncludeFile.h"
                #endif
                ***/

                and I use this form whenever I place an include statement in a header whether I am including one of mine or one from the compiler. Always ! Also - I usually take this even a bit farther. I make it a fatal error if a file is repeatedly included and this helps track them down quicker. This is done as follows :

                #ifndef _INCLUDEFILE_H
                #define _INCLUDEFILE_H
                #else
                #error repeated include of this file
                #endif

                You can comment off the #else and the #error if you don't want that to be a fatal error. In the past I have made the conversion to this style very quickly because it's easy to do and it has always resulted in significant improvements in compile time for me. In fact, generally speaking, the larger the project the larger the speed-up that I have seen. Now, this is only a compile time improvement so it does not address your link time issue. There are lots of variables involved in link time. Efficiency of the linker, amount of available memory, and hard drive speed are three biggies. Unfortunately I don't have any easy answers for this.

                I Offline
                I Offline
                InOut NET
                wrote on last edited by
                #7

                Cool maneuver. Here I always thought that it's less efficient if you have one Include header. Thanks!

                1 Reply Last reply
                0
                • S Stephen Hewitt

                  Things to look into: 1. Precompiled headers. 2. Unneeded include files. 3. Using abstract base classes as interfaces to avoid having to include class definitions.

                  Steve

                  I Offline
                  I Offline
                  InOut NET
                  wrote on last edited by
                  #8

                  Stephen Hewitt wrote:

                  3. Using abstract base classes as interfaces to avoid having to include class definitions.

                  Yeah this is what i want to hear. I was never sure. Currently my design lacks abstraction. But now - implementing and converting candidate classes will mean a huge design change. Thanks!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups