I am using "make" command to compile. I know if I use "make -jN", N indicates the job number. But if I don't use any number after -j, what does it mean?
2. Save this answer. The -j option tells make how many jobs (commands) to run in parallel. This is limited by how many physical CPUs and RAM your system has. Many make jobs use as many CPUs as it finds in the system.
Using -j alone tells make that it should run all the jobs that can possibly be built, without any consideration of system resources. It doesn't look at how many CPUs you have, how much memory you have, how high the load is on your system, or anything else.
The most straight-foward way is to use nproc like so: make -j`nproc` The command nproc will return the number of cores on your machine.
-j [jobs], --jobs[=jobs] Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously. -k, --keep-going.
No number means no limit.
From the GNU Make manual [emphasis mine]:
If the ‘
-j
’ option is followed by an integer, this is the number of recipes to execute at once; this is called the number of job slots. If there is nothing looking like an integer after the ‘-j
’ option, there is no limit on the number of job slots. The default number of job slots is one, which means serial execution (one thing at a time).
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