通过获取shell脚本在Qt Creator中设置环境变量

时间:2015-05-14 20:28:28

标签: shell environment-variables qt-creator

我正在尝试配置"运行设置"在Qt Creator 3.0.1上。

我想通过获取shell脚本' myScript'来设置许多环境变量的值。 但是,部署的自定义流程步骤显然不接受来源'作为一个命令。

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

是否可以使用' myScript'配置环境变量?我该怎么称呼它?

2 个答案:

答案 0 :(得分:1)

Ofcorse,你可以通过scrypt运行qt。这非常简单。我的脚本如下。 Ofcorse你需要concret文件中的环境变量。在我的情况下,此文件是 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

答案 1 :(得分:0)

我认为目前没有正确的方法来使用脚本设置QtCreator构建环境变量。例如,在this guide by 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.