Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_ctl: error while loading shared libraries: libpq.so.5

Tags:

postgresql

I'm trying to get postgres server status with:

sudo /etc/init.d/postgres status -u postgres

But getting following error:

/home/alex/olddisk/usr/local/pgsql/bin/pg_ctl: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

I added:

export LD_LIBRARY_PATH=""
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/alex/olddisk/usr/local/pgsql/lib/"

to my .bashrc, but it didn't help.

Thank you.

like image 940
0xAX Avatar asked Oct 29 '25 09:10

0xAX


2 Answers

I think this issue is duplicated, I faced the same problem and posted a solution here.

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 !

like image 148
Yahya Yahyaoui Avatar answered Oct 31 '25 03:10

Yahya Yahyaoui


I ran into this error when I built postgresql from source using the --prefix flag. Building from source installs the necessary shared libs to the libs folder under the prefix directory you specified, instead of the usual place installations put shared libs. To solve the problem I just added the [prefix].libs folder to the LD_LIBRARY_PATH environment variable. For example, after building postgres using --prefix /mike/sandbox/postgres, the below command solved the issue:

export LD_LIBRARY_PATH=/mike/sandbox/postgres/lib:$LD_LIBRARY_PATH

like image 41
mancini0 Avatar answered Oct 31 '25 02:10

mancini0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!