makefile参数中有“-j [;]”一项,默认是多少,可以设置吗

takeman 2014-06-19 01:18:37
如题,最近再用别人写的makefile,其中有个多依赖的,在用make的时候总是后面的依赖抢先执行导致编译失败,
加入“-j1”参数后就没有问题了。
请问makefile的并发执行的默认设置在哪个文件?
...全文
950 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
帅得不敢出门 2014-06-23
  • 打赏
  • 举报
回复
多核的 jn n大于1比1编译的快。
  • 打赏
  • 举报
回复
首先你可以man一下make,找到对于-j的定义:

 -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.
如果使用了"-j",但没有指定参数,则这时候jobs数目没有限制 然后再来看看Parallel Execution在Make manual里面的介绍:

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).
那么可以看到,如果不指定"-j"选项,则默认只有一个job。 除了在调用make的时候显示添加"-j',那么还有可能设置了环境变量MAKEFLAGS,又或者在MAKEFILE中设置了这个参数,也不排除其他可能。 至于你说的配置文件,我搜索过一些资料,并没有make对应的配置文件。
wusunjie123 2014-06-21
  • 打赏
  • 举报
回复
-j<N> N是线程数,指定N个线程进行make

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧