简体   繁体   English

QtCreator调试中的环境变量

[英]Environment variables in QtCreator debug

I'm developing an application under Debian 8 using QtCreator 3.4.0. 我正在使用QtCreator 3.4.0在Debian 8下开发一个应用程序。 The app uses some shared libraries, that I don't want to place in standard paths, like /usr/local/lib. 该应用程序使用了一些我不想放在标准路径中的共享库,例如/ usr / local / lib。

QtCreator adds paths to these to LD_LIBRARY_PATH environment variable. QtCreator将这些路径添加到LD_LIBRARY_PATH环境变量。 It works ok when running the app (ctrl+R) without debugger attached, but not when starting with debugger (F5). 在未连接调试器的情况下运行应用程序(ctrl + R)时,它可以正常运行,但在启动调试器(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? 问题是:是否可以将创建者配置为在调试时导出LD_LIBRARY_PATH而不在终端中运行,该怎么做?

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 . 可能您很久以前就解决了这个问题,但是今天我遇到了同样的问题,可以通过打开“ 工具/选项”对话框并在那里打开“ 调试器 ”部分和“ 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 . 此外,我还必须在Project / Build&Run中设置Run in terminal选项。
Now I was able so run the program in debug mode (of course I had to add -g in the build process). 现在,我可以在调试模式下运行程序了(当然,我必须在构建过程中添加-g )。

Interestingly enough this command did not work when I tried to use gdb in a terminal... 有趣的是,当我尝试在终端中使用gdb时,此命令不起作用...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM