设置 Qt Creator 的默认 make 选项?

发布于 2024-12-26 17:54:32 字数 383 浏览 3 评论 0原文

我如何覆盖默认的 make 参数,即:

make -w

每次创建项目时,我都必须修改项目设置,添加 -j4 来 make 参数。

我可以默认设置 make -w -j4 吗?

编辑

最好的方法是设置 MAKEFLAGS 环境变量,我选择唯一的答案作为最好的答案,仅关闭此线程。

要为 UNIX 设置此选项,请修改 Qt Creator 的 *.desktop 文件,在标题为 Exec= 的行前添加 env MAKEFLAGS=-j4 ,但请注意,您不会这样做设置为多线程后,无法立即停止 QtCreator 中的构建。

How can i override default make parameters , which is:

make -w

Each time i create a project , i had to modify project settings , adding -j4 to make parameters.

Can i set make -w -j4 by default ?

EDIT

The best way to do this is setting MAKEFLAGS environment variable , i'm picking the only answer as the best only to shut this thread down.

To set this for UNIX, modify the *.desktop file of Qt Creator , prefix the line entitled Exec= with env MAKEFLAGS=-j4 , but be aware that you won't be able to cease building in QtCreator immediately after setting to multithread.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

把时间冻结 2025-01-02 17:54:32

要使其全局且永久,请转到

Tools > Options > Build & Run > Kits > (pick your toolchain) 

并填写预定义的环境设置: MAKEFLAGS=-j4

To make it global and permanent go to

Tools > Options > Build & Run > Kits > (pick your toolchain) 

and fill your predefined env settings: MAKEFLAGS=-j4

Screenshot what to click exactly

妖妓 2025-01-02 17:54:32

在 qtcreator 中,转到“项目选项卡”并根据需要设置“创建参数”:
在此处输入图像描述

In the qtcreator go to the "Projects tab" and set "Make arguments" as you like:
enter image description here

幸福丶如此 2025-01-02 17:54:32

如果您希望每次创建新项目或打开某个项目时都将 -jx 参数设置为默认值,则必须将环境变量 MAKEFLAGS 添加到系统,其值为 -jx

例如,在 ubuntu 的 8 - 线程编译中,可以通过添加来实现此选项

MAKEFLAGS="-j8"

/etc/enviroments

结果将是:
在此处输入图像描述

If you want -jx parameter to be default each time you create a new or open some project, you must add enviroment variable MAKEFLAGS to your system with value -jx.

For example, at ubuntu for 8 - threding compilation this options can be realized by adding

MAKEFLAGS="-j8"

to /etc/enviroments

Result will be:
enter image description here

愁以何悠 2025-01-02 17:54:32

在尝试实现问题中描述的修复后,我最终发现了以下内容(显然这只是使用 .desktop 文件的 freedesktop 概念的 Linux 解决方案):

“/usr/local/share/applications/Nokia-QtCreator”中的行.desktop”是:

Exec=/opt/qtcreator-2.5.2/bin/qtcreator.sh %F

我将其更改为:

Exec=env MAKEFLAGS=-j16 /opt/qtcreator-2.5.2/bin/qtcreator.sh %F

并获得了问题中请求的功能。

好吧,我不知道为什么按照问题中的说明我没有到达那里,但我没有。我希望这个解释对某人有所帮助。

After attempting implement the fix described in the question I eventually found the following (clearly this in only a solution to linux's that use the freedesktop concept of .desktop files):

The line in "/usr/local/share/applications/Nokia-QtCreator.desktop" was:

Exec=/opt/qtcreator-2.5.2/bin/qtcreator.sh %F

I changed it to:

Exec=env MAKEFLAGS=-j16 /opt/qtcreator-2.5.2/bin/qtcreator.sh %F

And got the functionality requested in the question.

Ok, I have no idea why following the instructions in the question I didn't get there but I didn't. I hope this explanation will help someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文