Compiling with g++ using multiple cores

2019-01-07 02:22发布

Quick question: what is the compiler flag to allow g++ to spawn multiple instances of itself in order to compile large projects quicker (for example 4 source files at a time for a multi-core CPU)?

Many thanks.

8条回答
三岁会撩人
2楼-- · 2019-01-07 02:53

make will do this for you. Investigate the -j and -l switches in the man page. I don't think g++ is parallelizable.

查看更多
放我归山
3楼-- · 2019-01-07 03:01

People have mentioned make but bjam also supports a similar concept. Using bjam -jx instructs bjam to build up to x concurrent commands.

We use the same build scripts on Windows and Linux and using this option halves our build times on both platforms. Nice.

查看更多
登录 后发表回答