9

I have Qt Creator installed on Ubuntu 10.04 LTS. When I launch Qt Creator from the desktop I can build the application I am working on but cannot run or debug it. After struggling quite a bit I found that LD_LIBRARY_PATH is not set for applications that are run from the desktop. If I start Qt Creator from bash (where LD_LIBRARY_PATH is set in .bashrc) everything runs and debugs perfectly.

How do I set LD_LIBRARY_PATH so that it is set for all running applications?

Roger Light
  • 1,384
dwj
  • 191

4 Answers4

6

This seems like a bug in the application itself. It should have a wrapper script that correctly sets any needed LD_LIBRARY_PATH variables. Be careful when writing such a script, though, since you do not want to have any empty portion of the LD_LIBRARY_PATH string between the colons it uses as path separators. For example, this could result in a bad path, if the variable was empty initially (resulting in a leading empty string before the colon):

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/some/path/for/app"

So, when adding a path, you'll want to test for the empty string first. For example, using shell code:

LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/some/path/for/app
Kees Cook
  • 17,473
2

Create a new file /etc/ld.so.conf containing:

# Begin /etc/ld.so.conf
/lib
/usr/lib
/usr/X11R6/lib
# whatever else #

Update the dynamic loader cache by running:

ldconfig
Extender
  • 2,358
0

set it in /etc/bash.bashrc near the top to make a system wide change on bootup.

Roop
  • 41
  • 1
0

In addition to .bashrc, also set the environment variable in .profile. This file will get processed and loaded by your session, so it should affect everything running as your user. Also: This file says it is not read by Bash if .bashrc exists, but it seems to apply still (perhaps since Bash inherits the X session from where it was started). It doesn't hurt to have the variable in both files, though.

  • I tried creating .profile as well with no luck. – dwj Oct 28 '10 at 16:44
  • I read somewhere that there is a "safety" feature of Ubuntu(Debian?) that can't let you set LD_LIBRARY_PATH at startup since it is overwritten after loading .profile. There are still workarounds. – alfC Nov 07 '11 at 06:32
  • https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/47958 – Eero Aaltonen Oct 02 '14 at 15:00