Re: psql undefined symbol error on Ubuntu

From: Michael Wood <esiotrot(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: psql undefined symbol error on Ubuntu
Date: 2009-07-09 15:20:57
Message-ID: 5a8aa6680907090820r291c50d2re284a37ae2dd622a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I sent this directly to Harsha by mistake:

Hi

2009/7/8 Harsha Hegde <harsha(dot)hegde(at)vonage(dot)com>:
>
> Hello Friends,
>
> I have installed postgres client on an Ubuntu machine. However, when I
> try to run 'psql', I get this error message:
>
> # psql
> /usr/lib/postgresql/8.3/bin/psql: symbol lookup error:
> /usr/local/lib/libreadline.so.5: undefined symbol: PC

Google returns many results for the error
"/usr/local/lib/libreadline.so.5: undefined symbol: PC". It is not
clear to me why so many people encounter this error, though.

By the way, why do you have a libreadline.so.5 in /usr/local/lib?
Official Ubuntu packages are never installed to /usr/local. I think
the problem is that psql is finding the wrong libreadline.

What does this give you:
ldd /usr/lib/postgresql/8.3/bin/psql

In order to get psql to use the correct libreadline, you have several options.
1.) Remove the one from /usr/local/lib and then run "ldconfig", but
this might break other things. Since it should not have been
installed there by official Ubuntu packages, I hope you know what it
is that needs it and can decide if this is a problem. If you try
this, first rename it to something else and see what breaks. Then you
can rename it back again if necessary.

2.) Configure ld.so.conf (or ld.so.conf.d/*) to ignore /usr/local/lib
(i.e. comment it out. It should be in /etc/ld.so.conf.d/libc). Then
run "ldconfig". This is similar to option 1. i.e. it could break
other things, but should not break any official Ubuntu packages.

3.) Configure ld.so (same files as for option 2) so that /lib and
/usr/lib are before /usr/local/lib when you run "ldconfig -v". Not
sure about this, but you might just be able to put them above
/usr/local/lib in /etc/ld.so.conf.d/libc. This should be safe, but
keep a live CD handy in case. Remember to run "ldconfig" after
changing the files.

4.) Use LD_PRELOAD to force psql to use the correct libreadline.
This is the ugliest solution and you would have to do it every time
you run psql (or write a script that does this), so I don't recommend
it:

LD_PRELOAD=/lib/libreadline.so.5 psql

also, I haven't tested it. It won't break anything and I'm pretty
sure it will work, but as I said, it's ugly.

The best solution, I think, is number 1, but only if you don't
actually need the version in /usr/local for some reason.

I hope this helps and is not too confusing :)

--
Michael Wood <esiotrot(at)gmail(dot)com>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Gould 2009-07-09 15:23:02 Setting up security for development
Previous Message Michael Wood 2009-07-09 15:18:21 Re: psql undefined symbol error on Ubuntu