13

I am trying to make the postgis extension work on my system and it always spits out "$libdir/postgis2.2" no such file or directory error. For my curiosity I executed "ldd postgis-2.2.so" and it spits out the following result :

    linux-vdso.so.1 =>  (0x00007ffff3bc8000)
    /usr/lib64/libjemalloc.so.1 (0x00002b3fe5ff4000)
    libgeos_c.so.1 => not found
    libproj.so.9 => not found
    libjson-c.so.2 => not found
    libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00002b3fe6237000)
    libm.so.6 => /lib64/libm.so.6 (0x00002b3fe659e000)
    libc.so.6 => /lib64/libc.so.6 (0x00002b3fe689c000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b3fe6c41000)
    /lib64/ld-linux-x86-64.so.2 (0x00002b3fe5b2e000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00002b3fe6e5d000)
    libz.so.1 => /lib64/libz.so.1 (0x00002b3fe7061000)
    liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00002b3fe7277000)

And for a bunch of dependencies I see the path to their so is not present. This I guess is happening because I am not building postgis but just copying the required so's and libs to make it work manually. But I do know the path to those so files that are required by postgis. What should I do such that I can change the "not found" in dependencies to the required path by postgis?

5
  • Can you edit your answer to post the output from ldconfig -v? Aug 18, 2016 at 5:15
  • Are those libraries already installed? Did you follow the installation instructions provided by postgis? Aug 18, 2016 at 5:27
  • I stored the so files manually including the libs and bins. Aug 18, 2016 at 5:42
  • It's a hack I want urgent in my project so trying to make it work Aug 18, 2016 at 5:45
  • Well make sure the libraries that it doesn't find are in a directory present in your /etc/ld.so.conf. Aug 18, 2016 at 6:16

2 Answers 2

10

ld.so, the dynamic linker, will use the PATH-like environment variable LD_LIBRARY_PATH when it looks for shared libraries to link at execution time.

You may set LD_LIBRARY_PATH to a :-delimited list of directories where the linker should look for libraries, for example:

$ env LD_LIBRARY_PATH="$HOME/local/lib:/opt/other/lib" ./myprog

See the ld.so manual on your system for more information.

0
10

This has been covered in part in many tutorials, but I feel many of the solutions are missing a basic example.

Assuming you're using for Linux:

Note: patchelf is not installed by default on many systems. You can install it using apt install patchelf, dnf install patchelf, pacman install patchelf or whatever your package manager provides.

patchelf --print-needed mysharedobject.so

# outputs:
../libsomething1.so
libsomething2.so.1

Replace the path to a required library:

patchelf --replace-needed ../libsomething1.so /foo/bar/libsomething1.so mysharedobject.so

Test the new path:

patchelf --print-needed mysharedobject.so

# outputs:
/foo/bar/libsomething1.so 
libsomething2.so.1

Note: Many tutorials recommend another tool called chrpath which can help .so files that have a rpath attribute set but it does not appear to work with libraries missing rpath nor have the ability to change the absolute link location.

2
  • patchelf --replace-needed does the job , however the rpath printed by ldd remains same as original dependency path Aug 23, 2022 at 19:12
  • 1
    I believe you will want to use chrpath for that.
    – tresf
    Aug 25, 2022 at 0:51

You must log in to answer this question.

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