I currently have a machine with an Opteron 275 (2.2Ghz), which is a dual core CPU, and 4GB of RAM, along with a very fast hard drive. I find that when compiling even somewhat simple projects that use C++ templates (think boost, etc.), my compile times can take quite a while (minutes for small things, much longer for bigger projects). Unfortunately only one of the cores is pegged at 100%, so I know it's not the I/O, and it would seem that there is no way to take advantage of the other core for C++ compilation?
Are you using pre-compiled headers? They typically provide the biggest compilation speed boost I get with my C++ projects.
Also, depending on your compiler, you can enable multi-thread compiling. For example, with Visual C++, it's the /MP switch (see here for details), though enabling /MP isn't always possible, depending on what other command-line options you use.
Compile time problems with templates are often link problems, rather than compilation problems.
Using templates internally in your .cpp files, but making sure that the headers don't actually include the template, is a good way to fix those. That can be done by either forward declaring the class, or wrapping your implementation class in an abstract base class that just declares the public members (the Pimpl Idiom, basically).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With