Is there a faster c++ compiler for Linux?
In C, I could use the tcc, but I wasn't able to find anything for c++.
A single .cpp file changed in Eclipse with the Gcc takes ~5 seconds to recompile, that's ridiculous. I don't 开发者_开发问答care about how the code performs, I just need a faster testing cycle.
Any ideas to make the code compile faster?
For a 50-line file on my not very fast laptop, compile times are of the order of 1.5 seconds with g++ from the command line - obviously this depends on a lot of other factors, like what headers are included. For the Code::Blocks IDE, which is written in C++, compilation of the same files (or to be more accurate, reporting the results of compilation) is perhaps double this. I'm not surprised that an IDE written in Java is even slower.
Check out clang
Eclipse is taking so much RAM, it's not unlikely that your operating system starts swapping when it has to run a compiler too.
In 2018 there is clang-based compiler called zapcc. It is at least 2x faster on first build and more than 20x faster on rebuild due to caching.
However, it require much more memory than gcc or clang.
May be a workaround might be to divide the C++ project to sub-components and compile the whole project with some high optimization level. Then, during development, recompile only the parts that changed with no optimization at all by using GCC/LLVM flag -O0
(letter "o" and digit "zero").
The key part to such a solution is a fine build system. As of 2015 I use Rake, which is a Ruby analogue to the GNU Make. Rakefile is an ordinary Ruby file that just loads a Rake specific library. The Rake tasks are essentially global Ruby functions, which means that anything that can be written in Ruby, can be executed from a Rake task. As of 2015 I use Rake tasks for starting self-tests, starting tests of a specific component (during the "test driven development"), building, code generation, etc.
- As of 2015 the corporate Java world seems to like Gradle, which is a successor of the Apache Maven, which is a successor of the Apache Ant.
- Open source scientific C++ software projects seem to find CMake practical. The Boost C++ library seems to offer Boost.Build.
On multi-core CPU's the classical GNU Make can build multiple files in parallel, if it receives the -j
command line option.
精彩评论