Set run environment from script in QtCreator

  • Hi,

    Is there a way to have a shell script automatically sourced to set the run environment in QtCreator (4.3.0, if that matters -- and on Linux obviously)?

    My projects use CMake and at one step it generates a bash script with a lot of environment variables. This script is specific to each project, and its content may change depending on some of the options that are passed to CMake (such as which modules are to be included in the project and so on), so I cannot simply edit my user environment. The normal way to start the program (i.e. not through QtCreator) is to call another script that first source this one to set the variables and then launches the executable.

    At the moment, whenever that file changes, I have to go to the run environment and use the "Batch Edit..." option, then copy-paste the content of the file in there. This is obviously not ideal, I sometime forget that the script has changed and get weird results in my application because of that... Plus, any copy-paste is a source of potential errors!

    So, is there a way I could tell QtCreator to automatically source that script before running the application, instead of doing that manually?

    I know that I can set a custom executable as the run target (i.e. the script that source the environment script + launches the true executable), but doing so means that e.g. starting the debugger directly doesn't work as it tries to debug the script and not the executable!

    I've also found another question that seems exactly identical to what I want to do, but it is from 2015 and hasn't got a single answer, so hopefully someone will have an idea now?


  • @rmoyen , Did you ever find a solution to your problem? I having exactly the same issue on Ubuntu and would really like to know if there is a good answer for it.

  • Qt Champions 2018


    I'm not aware that would be possible, beside the mentioned custom executable.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.