Problem with setting LD_LIBRARY_PATH

Discussion in 'Perl Misc' started by Moritz Karbach, Apr 21, 2005.

  1. Hi experts,

    I'd like to run a program out of a perl script. The program needs a special
    library path, which I'd very much like to set inside the perl script. Here
    is what I tried:

    --- perl script ---

    #!/usr/bin/perl -w
    $ENV{'LD_LIBRARY_PATH'} .= ":" . `pwd`;
    exec 'ldd', 'fplist';


    --- output ---
    ....
    libreadline.so.4 => /lib/libreadline.so.4 (0x40a9a000)
    ....


    That is, the fplist program still uses the system library instead of using
    the one in the working directory. It works, if I do it completely on the
    shell:

    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`
    $ ldd fplist
    ....
    libreadline.so.4 =>
    /afs/desy.de/user/m/mkarbach/h1/grid/h1mcjobwrapper/libreadline.so.4
    (0x40a9a000)
    ....


    Can anybody tell me, what the problem is?

    Thanks,

    - Moritz
    Moritz Karbach, Apr 21, 2005
    #1
    1. Advertising

  2. Moritz Karbach

    Steven Kuo Guest

    On Thu, 21 Apr 2005, Moritz Karbach wrote:

    > Hi experts,
    >
    > I'd like to run a program out of a perl script. The program needs a special
    > library path, which I'd very much like to set inside the perl script. Here
    > is what I tried:
    >
    > --- perl script ---
    >
    > #!/usr/bin/perl -w
    > $ENV{'LD_LIBRARY_PATH'} .= ":" . `pwd`;




    Forgot that the output from `pwd` includes newline at the end?



    > exec 'ldd', 'fplist';
    >
    >
    > --- output ---
    > ...
    > libreadline.so.4 => /lib/libreadline.so.4 (0x40a9a000)
    > ...
    >
    >
    > That is, the fplist program still uses the system library instead of using
    > the one in the working directory. It works, if I do it completely on the
    > shell:
    >
    > $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`
    > $ ldd fplist
    > ...
    > libreadline.so.4 =>
    > /afs/desy.de/user/m/mkarbach/h1/grid/h1mcjobwrapper/libreadline.so.4
    > (0x40a9a000)
    > ...
    >
    >
    > Can anybody tell me, what the problem is?



    See perldoc -f chomp
    and perldoc -f qx


    --
    Hope this helps,
    Steven
    Steven Kuo, Apr 21, 2005
    #2
    1. Advertising

  3. Steven Kuo wrote:

    > Forgot that the output from `pwd` includes newline at the end?


    Aaaarrg! That was exactly the problem! So f** simple! And I spent hours in
    googling before I asked here...

    Thanks a lot,

    - Moritz
    Moritz Karbach, Apr 21, 2005
    #3
  4. Steven Kuo wrote:

    > Forgot that the output from `pwd` includes newline at the end?


    Aaaarrg! That was exactly the problem! So f** simple! And I spent hours in
    googling before I asked here...

    Thanks a lot,

    - Moritz
    Moritz Karbach, Apr 21, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Eriksson

    Problem using LD_LIBRARY_PATH in perl script

    Christian Eriksson, Nov 24, 2003, in forum: Perl
    Replies:
    1
    Views:
    3,202
  2. Naresh Agarwal
    Replies:
    0
    Views:
    833
    Naresh Agarwal
    Jun 30, 2005
  3. Simon John
    Replies:
    2
    Views:
    696
    Simon John
    Sep 19, 2004
  4. Spitfire
    Replies:
    2
    Views:
    16,020
    Thomas Fritsch
    Feb 15, 2007
  5. Lax
    Replies:
    2
    Views:
    362
    Peter J. Holzer
    Apr 14, 2007
Loading...

Share This Page