Important: Please read the Qt Code of Conduct -

Startup Directory Problem

  • I'm building a shell in Qt that drives a program built externally. I'm having trouble getting the debug environment configured using Qt Creator 4.12.3 under Ubuntu 20.04. My project is cmake based. (Previous work always used qmake, so this piece is new to me.) The Qt interface builds correctly and I have a custom build step that copies the executable to the correct run time folder. That folder contains files that must be read at startup, along with several project libraries. I have the Qt Creator "Working Directory" setting for the Run settings pointing to the run time folder as well. The Qt application built this way runs as expected when started from a Linux terminal.

    When I try to run the built application from inside of Qt Creator, either with the debugger or without it by pressing the "play" button, the application fails to launch and indicates that it cannot find the application libraries. The application acts as if it is running them the Qt build folder ("build-GTK-Desktop_Qt_5_15_0_GCC_64bit-Debug" for my desktop application named GTK) rather than from the folder that I need it to use. How do I set the application startup folder for runs made inside of the debugger?

    (I expected the "Working Directory" setting to do this, but it does not seem to be what I need with this configuration.)

  • Moderators

    Uncheck the checkbox Projects->Build->Shadow build and rebuild your project.

  • @sierdzio I don't see a "Shadow build" setting for a CMake based project. I do see it for qmake, but I'm configured in CMake for this project.

  • Qt Champions 2019

    @DJCinSB For CMake projects you can specify the build folder in QtCreator

  • @jsulm That approach is okay, I guess (sighs), but it leaves cmake crap in the build folder. (Basically the CMakeFiles folder tree and an autogen folder tree.) For my project, the build folder is a bin folder inside of a fairly structured folder tree containing a few hundred files (data files, libraries, sample scripts, and so forth). I'd prefer to have my application placed in a target folder and launched in that folder , and the build files stored outside of that folder tree.

    The main project - which uses wxWidgets where I prefer Qt - already builds that way using CMake files. Running it in GDB/Eclipse with that configuration works as expected without having the application and build files commingled; I only need to set the run folder. I had hoped that the "Working directory" setting in Qt Creator would cd to that folder and then run the application, but it appears that it runs the app from the build folder. (I'm not clear about what the working directory setting under Run setting does at this point if it isn't the folder used for the run.) My preference is to have the Qt configuration version be as close as possible to the wx setup.

    If I don't just build in my bin folder, I may need to hack in some pieces to the Qt CMakeLists file, but I'd prefer to follow some general "best practice" guidelines rather than do something (hackish and) project specific.

  • Hi, you can try adding a "Custom executable" run configuration, i.e. in the Run settings click "Add..." and then select "Custom Executable" then click Browse to select your custom run time folder and the .exe/elf file in there.

Log in to reply