3
votes

I'm developing an application under Debian 8 using QtCreator 3.4.0. The app uses some shared libraries, that I don't want to place in standard paths, like /usr/local/lib.

QtCreator adds paths to these to LD_LIBRARY_PATH environment variable. It works ok when running the app (ctrl+R) without debugger attached, but not when starting with debugger (F5). It also works if "run in terminal" checkbox is selected.

The question is: Is is possible to configure the creator to export LD_LIBRARY_PATH when debugging and not running in terminal and how to do it?

1
If you are using qtcreator's Project/Build & Run/System Environment, then you need to set manual environment variables separately for each build configuration. - Amartel
The problem is within one configuration - debug. The only difference is "run in terminal" checked or not. It seems, that session with LD_LIBRARY_PATH dies before program starts without terminal. - Oleg Glazov
I use QtCreator 3.3.0. In Project/Build & Run I switched to Run, opened Run Environment, selected System Environment in combobox and edited LD_LIBRARY_PATH (removed needed path). It took expected effect both with and without Run in terminal checkbox. Try to do the same thing. - Amartel
Indeed, removing needed path from 'LD_LIBRARY_PATH' stopped app from starting in cases when it did start before, but it doesn't help in cases when it didn't. It seems, that GDB uses it's own enviroment and it doesn't include 'LD_LIBRARY_PATH'. I will try to use custom run script to fill 'LD_LIBRARY_PATH' manually. - Oleg Glazov

1 Answers

2
votes

Probably you solved the problem a long time ago but I've run into the same problem today and could solve it by opening the Tools/Options dialogue and there opening the section Debugger and the tab GDB.
In the field Additional Startup Commands I added the following:

set environment LD_LIBRARY_PATH /usr/local/lib/

Moreover I had to set the Run in terminal option in Project/Build&Run.
Now I was able so run the program in debug mode (of course I had to add -g in the build process).

Interestingly enough this command did not work when I tried to use gdb in a terminal...