Error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

McKibet picture McKibet · Oct 8, 2012 · Viewed 87.8k times · Source

I am trying to execute pg_dump on PostgreSQL 9.0.4 server running on Debian and I am getting the error below:

./pg_dump: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory 

libpq.so.5 is a link to libpq.so.5.3 as shown below

lrwxrwxrwx 1 root root     12 Jun 27 16:24 libpq.so.5 -> libpq.so.5.3
-rwxr-xr-x 1 root root 180749 Jun 21 02:43 libpq.so.5.3

What is it that I am doing wrong?

Answer

Yahya Yahyaoui picture Yahya Yahyaoui · Mar 12, 2015

Try this:

1: Know the path of libpq.so.5

find / -name libpq.so.5

Output example: /usr/pgsql-9.4/lib/libpq.so.5 If found nothing, check if you have already installed the suitable postgresql-libs for your postgresql version and your OS platform

2: Symbolic link that library in a "well known" library path like /usr/lib:

ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib/libpq.so.5

Attention: If your platform is 64 bit, you MUST also symbolic link to 64 bit libraries path:

ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib64/libpq.so.5

3: Be happy !