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?

4 Answers 4

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
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
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.

3
  • I tried creating .profile as well with no luck.
    – dwj
    Oct 28, 2010 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 7, 2011 at 6:32
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .