通过执行shell脚本设置Qt Creator的环境变量

11

我正在尝试配置Qt Creator 3.0.1上的“运行设置”。

我希望通过调用一个名为“myScript”的shell脚本来设置多个环境变量的值。然而,“部署(Deployment)”中的自定义进程步骤似乎不接受“source”命令。

如果我执行该脚本而不是调用它,它会设置在执行它的shell进程的环境变量,这与Qt Creator运行可执行文件的进程不同。

是否有可能使用“myScript”来配置环境变量?我该如何调用它?

3个回答

2

当然,您可以通过脚本运行qt。这非常简单。我的脚本如下。当然,您需要在具体文件中设置环境变量。在我的情况下,这个文件是 environment-setup

#!/bin/bash
echo "ustawienie zmiennej /usr/local/angstrom/arm/environment-setup"
# set concret variables important is . /
. /usr/local/angstrom/arm/environment-setup
echo "Uruchomienie qtCreator"
# lunched qtcreator
$HOME/Qt/Tools/QtCreator/bin/qtcreator

您还可以将此脚本设置为与主图标qt链接,以便在开始菜单中使用。之后,运行qt所需的所有操作仅需要点击菜单中的快捷方式。


3
谢谢您的回复,但我的问题是关于如何在Qt Creator启动后设置环境变量。我需要这样做才能拥有不同的“运行设置”(在Qt Creator内),并轻松地在它们之间切换。 - toliveira

0

我认为目前没有适当的方法可以使用脚本设置QtCreator构建环境变量。例如,在ICS的这个指南中,“设置环境”部分提到了三个选项:

1. You can always start Qt Creator in the same shell/console session where you previously ran the environment setup script (i.e. /opt/poky/2.2.1/environment-setup-armv5e-poky-linux-gnueabi). This option is the easiest, but means that you can’t simply launch Qt Creator from a desktop shortcut or similar method. It might also cause problems if you want to build for the desktop or another embedded platform within the same session.
2. You can add the environment variables to the kit’s settings. This option is a little more work to set up, but avoids the issues of the shell setup.
3. A third option is to add the environment variables to your project settings, but that means adding it to every project that uses the kit.

0
一个解决方法是在命令行中启动QT Creator,并在启动前先加载包含必要环境变量的脚本。
source path/to/myScript
qtcreator

这将在您当前的bash/zsh会话中加载在myScript中声明的环境变量,然后使用当前bash/zsh会话中的所有环境变量启动QT Creator。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接