Find the answer to your Linux question:
Results 1 to 5 of 5
I am using an opensource utility wav2png. When I execute it through shell by any user it works fine. I uses a library libsndfile, which is placed at /usr/local/lib. I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2011
    Posts
    1

    environment variable for daemon


    I am using an opensource utility wav2png. When I execute it through shell by any user it works fine. I uses a library libsndfile, which is placed at /usr/local/lib. I added this path to PATH env variable. I added this path to PATH variable and export command for update PATH in /etc/profile.
    But when I call wav2png command using system() in php, it says cannot found shared library libsndfile. and when printed the PATH through system command /usr/local/lib is not there..
    I tried to add my library path through putenv method of php, but no luck.. If anybody can help me, I will be very thankful

  2. #2
    Linux Newbie
    Join Date
    Jun 2004
    Location
    Halesowen, West Midlands, UK
    Posts
    107
    This is an ancient script I have lying around which should give you an idea
    -------------------------------------------------------
    #!/bin/sh
    LD_PRELOAD=/libdl.so.2:/libc.so.6
    export LD_PRELOAD
    /opt/MultiLink/bin/Viewer&
    -------------------------------------------------------

    An alternative method would be to have a script with export
    #!/bin/sh
    export LD_LIBRARY_PATH=/usr/local/lib
    wav2png

    Hope that helps.

  3. #3
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Siddly's got it. Another thing you can do is put the lib's directory in a file on a single line in the directory /etc/ld.so.conf.d/ and give the file a .conf file extension.

    So, for example, you could create a file called /etc/ld.so.conf.d/local.conf and in it put:
    Code:
    /usr/local/lib
    Then run a command to update the shared library cache on the system:
    Code:
    ldconfig
    Now look for your library in the cache:
    Code:
    ldconfig -p|grep wav2png
    If you see it, then you should be able call wav2png from the command line without having to worry about the location of the library.

    Btw, this is what works for me on Fedora/RH based systems. ymmv.

  4. #4
    Linux Newbie
    Join Date
    Jun 2004
    Location
    Halesowen, West Midlands, UK
    Posts
    107
    Quote Originally Posted by atreyu View Post
    Siddly's got it. Another thing you can do is put the lib's directory in a file on a single line in the directory /etc/ld.so.conf.d/ and give the file a .conf file extension.

    So, for example, you could create a file called /etc/ld.so.conf.d/local.conf and in it put:
    Code:
    /usr/local/lib
    Then run a command to update the shared library cache on the system:
    Code:
    ldconfig
    Now look for your library in the cache:
    Code:
    ldconfig -p|grep wav2png
    If you see it, then you should be able call wav2png from the command line without having to worry about the location of the library.

    Btw, this is what works for me on Fedora/RH based systems. ymmv.
    Having a separate entry in /etc/ld/so/conf.d also will do the job, there are always many ways to skin the cat.

  5. #5
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Siddly View Post
    Having a separate entry in /etc/ld/so/conf.d also will do the job, there are always many ways to skin the cat.
    Indeed, that is the bane, and the beauty of Linux.

Posting Permissions

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