Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2011
    Location
    Canada
    Posts
    10

    [SOLVED] cannot set LD_LIBRARY_PATH in ~/.profile, /etc/profile


    Hello all,

    I am using Ubuntu 10.04 64bit. I got problems when trying to add LD_LIBRARY_PATH as a global environment variable.

    Code:
    export LD_LIBRARY_PATH=/usr/local/Coin/lib:$LD_LIBRARY_PATH
    I tried adding the above line to ~/.profile and /etc/profile, logged out and in, but neither of them worked.

    Actually I want to run a program from the graphical environment which needs to find the shared library from /usr/local/Coin/lib.

    Adding the above line to ~/.bashrc or /etc/bash.bashrc can make the LD_LIBRARY_PATH visible in the command line, but not global. So the program wouldn't see the path and wouldn't start.

    I can start the program from the command line to get around this problem. But just curious why that happened and how we can fix it?

    It seems that the LD_LIBRARY_PATH is either reset during the system startup , or ignored in ~/.profile and /etc/profile.

    Any idea about this? Thank you very much.

  2. #2
    Hmm. So, if you add the above variable to /etc/profile, log-in and out, you can't see the path listed?

    Code:
    echo $LD_LIBRARY_PATH
    If your trying to install Coin3D, make sure the other important variables are set too:

    Code:
    export COINDIR=/usr/local/Coin
    export PATH=$PATH:/usr/local/Coin/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$COINDIR/lib
    Try throwing the above into one of your startup scripts. Let me know how it goes!

  3. #3
    Just Joined!
    Join Date
    Feb 2011
    Location
    Canada
    Posts
    10
    When I add the variable to /etc/profile or ~/.profile, log-in and out,
    Code:
    echo $LD_LIBRARY_PATH
    , it shows nothing. And adding the variable to bashrc shows the variable in the command-line but not visible to desktop programs.

    I did set all the important variable you mentioned there. All the variables work fine except for LD_LIBRARY_PATH.

    I am running a program which calls the library of Coin3D. I can start the program from command-line where the LD_LIBRARY_PATH is visible but not directly from desktop. Curious about if there's anyway to set the LD_LIBRARY_PATH globally.

    Thank you

  4. $spacer_open
    $spacer_close
  5. #4
    Damn.. That's strange, all you should need to do (from what I know of) to set a global variable is use the export command. I'll do some more research on this once I get out of work. This is bugging me now.

    One thing you could try doing as a workaround is make symbolic links in the '/usr/lib' directory to the library .so files in '/usr/local/Coin/lib'. The linker should be checking /usr/lib and will find them there. Actually, unless I'm mistaken, I believe the majority of data in there are actually sym links.

    Just an idea, hopefully we can get to the root of the problem.

  6. #5
    Just Joined!
    Join Date
    Feb 2011
    Location
    Canada
    Posts
    10
    Thank you for you suggestion on the "symbolic" workaround, actually I tried before and it worked. And yes most data there are sym links.

    Wait..I think I just found the doc about the problem.
    From "https://help.ubuntu.com/community/EnvironmentVariables/"

    Since Ubuntu 9.04 Jaunty Jackalope, LD_LIBRARY_PATH cannot be set in $HOME/.profile, /etc/profile, nor /etc/environment files. You must use /etc/ld.so.conf.d/*.conf configuration files. See Launchpad bug #366728 for more information.
    I will look into it and find a way out.
    Last edited by ifonly; 03-31-2011 at 05:51 PM.

  7. #6
    Just Joined!
    Join Date
    Feb 2011
    Location
    Canada
    Posts
    10
    Following that link "https://help.ubuntu.com/community/EnvironmentVariables" and related bug reports, I tried two workarounds to set LD_LIBRARY_PATH a gnome global environment variable. I list them here for who is interested in it. They both worked. Thank you for your help Nagarjuna~



      • Add the ld.so configuration file:
        Code:
        echo "/usr/local/Coin/lib" | sudo tee /etc/ld.so.conf.d/libcoin.conf
        (note that, "/usr/local/Coin/lib" is the runtime library path that I want to add in the LD_LIBRARY_PATH as a global enrironment variable. While libcoin.conf is a new file I created, it can be whatever name)
      • Then we need update the cache
        Code:
        sudo ldconfig -v

    1. Add LD_LIBRARY_PATH in ~/.profile or /etc/profile.
      Then open /etc/X11/Xsession.options, change
      Code:
      use-ssh-agent
      to
      Code:
      no-use-ssh-agent
      Then log out and in.

  8. #7
    Hey, you did it all your self! I'm happy you found the solution to your issue.

    It's good to know about this /etc/ld.so.conf.d/ directory. This might come in use if I ever run a Ubuntu machine.

    Have fun.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •