这个问题可能有点奇怪,但我怎样才能加快 g++ 编译时间?我的 C++ 代码大量使用 boost 和模板.我已经尽可能多地移出头文件并使用 -j 选项,但编译(和链接)仍然需要很长时间.
This question is perhaps somehow odd, but how can I speed up g++ compile time? My C++ code heavily uses boost and templates. I already moved as much as possible out of the headers files and use the -j option, but still it takes quite a while to compile (and link).
是否有任何工具可以分析我的代码并指出编译器的瓶颈?或者可以以某种方式分析在我的代码上运行的编译器?这真的很好,因为有时我会有这样的印象,我花了太多时间盯着编译器控制台日志......
Are there any tools out there which analyse my code and point out bottle-necks for the compiler? Or can one somehow profile the compiler running on my code? This would be really nice, because sometimes I have the impression, that I spent too much time staring at the compiler console log ...
对我最有用的:
-j3
进行 make.不过,请确保您的 Makefile 中的依赖关系图正确无误,否则您可能会遇到问题.-O0
.-j3
globally for make. Make sure your dependency graphs are correct in your Makefile, though, or you may have problems.-O0
if you're not testing execution speed or code size (and your computer is fast enough for you not to care much about the (probably small) performance hit).这篇关于如何加快 g++ 编译时间(使用大量模板时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!