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

问题描述 投票:0回答:3

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

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

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

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

shell environment-variables qt-creator
3个回答
2
投票

Ofcorse,您可以通过 scrypt 运行 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


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
投票

source path/to/myScript qtcreator

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

© www.soinside.com 2019 - 2024. All rights reserved.