Compile- and Linking Time Tips
-
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
-
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
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:
-
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
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
#endifYou 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.
-
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
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
-
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
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
-
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
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:)
-
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
#endifYou 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.
-
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
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!