Thread: Can't not load libpq.so.3

Can't not load libpq.so.3

From
"Fabien DAUMEN"
Date:
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-GB" style="font-size:
10.0pt;font-family:Arial">I have install postgresql 7.3.4. I want to use C++ program to update my
database.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span lang="EN-GB" style="font-size: 
10.0pt;font-family:Arial">I link my program with this link option –L/usr/local/pgsql/lib.</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span lang="EN-GB" style="font-size: 
10.0pt;font-family:Arial">The program is linked, but when I run it.</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span lang="EN-GB" style="font-size: 
10.0pt;font-family:Arial">I have this problem</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
lang="EN-GB"style="font-size: 
10.0pt;font-family:Arial">My_program: <b><i><span style="font-weight:bold;
font-style:italic">error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or
directory</span></i></b>.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span lang="EN-GB"
style="font-size:
10.0pt;font-family:Arial">The link libpq.so.3 is the right directory /usr/local/pgsql/lib and it’s linked to
libpq.so.3.0.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span lang="EN-GB" style="font-size: 
10.0pt;font-family:Arial">What happening?</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
lang="EN-GB"style="font-size: 
10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-GB"
style="font-size:
10.0pt;font-family:Arial">Thanks.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span lang="EN-GB"
style="font-size:
10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size:
12.0pt">Sincères Salutations.</span></font><p style="margin-left:141.6pt;text-indent:35.4pt"><span
style="z-index:-1"><spanstyle="position:absolute;z-index:-1;left:0px;margin-left:-2px;margin-top:7px; 
width:1024px;height:195px"><img height="195" src="cid:image001.gif@01C396F1.A055FB20" width="1024"
/></span><strong><b><fontcolor="navy" face="Comic Sans MS"><span style="font-family:"Comic Sans MS";color:navy">Fabien
DAUMEN- Chef de projet.</span></font></b></strong></span><p style="margin-left:177.0pt"><strong><b><font color="navy"
face="ComicSans MS" size="3"><span style="font-size:12.0pt;font-family:"Comic Sans MS"; 
color:navy">NEOPOST – NBG</span></font></b></strong><p style="margin-left:177.0pt"><font color="navy" face="Comic Sans
MS"size="2"><span style="font-size:10.0pt;font-family:"Comic Sans MS";color:navy">MIN 26, Halle 4   -   84953 CAVAILLON
CEDEX -  FRANCE</span></font><p style="margin-left:141.6pt;text-indent:35.4pt"><font color="navy" face="Comic Sans MS"
size="2"><spanstyle="font-size:10.0pt;font-family:"Comic Sans MS"; 
color:navy">Tél: (33) 4.90.76.08.08   -   Fax: (33) 4.90.06.18.86</span></font><p
style="margin-left:141.6pt;text-indent:35.4pt"><fontcolor="maroon" face="Comic Sans MS" size="2"><span
style="font-size:10.0pt;font-family:"ComicSans MS"; 
color:maroon"><a href="http://www.neopost.com/lsthis"
target="_blank">http://www.neopost.com/ls</a></span></font><p><i><u><fontcolor="purple" face="Comic Sans MS"
size="1"><spanlang="EN-GB" style="font-size:7.5pt;font-family:"Comic Sans MS";color:purple;font-style: 
italic"><a href="http://www.neopost.com/lsthis" target="_blank"><font color="purple"><span
style="color:purple">This</span></font></a></span></font></u></i><i><fontcolor="purple" face="Comic Sans MS"
size="1"><spanlang="EN-GB" style="font-size: 
7.5pt;font-family:"Comic Sans MS";color:purple;font-style:italic"> e-mail and any files transmitted with it are
confidentialand intended solely for the use of the individual or entity to whom they are addressed. If you have
receivedthis e-mail in error please notify the system manager</span></font></i><p class="MsoNormal"><font face="Times
NewRoman" size="3"><span lang="EN-GB" style="font-size:12.0pt"> </span></font><p class="MsoNormal"><font face="Times
NewRoman" size="3"><span lang="EN-GB" style="font-size:12.0pt"> </span></font></div> 

Re: Can't not load libpq.so.3

From
"Jeroen T. Vermeulen"
Date:
On Mon, Oct 20, 2003 at 10:12:28AM +0200, Fabien DAUMEN wrote:
> 
> I link my program with this link option ?L/usr/local/pgsql/lib.
That's good, but it only deals with the compile-time linking.  The
actual loading of a shared library happens at run-time, and since there's
no special reason to assume that the running system will look like the
one you compiled your code on, this library path is not remembered.

So libpq needs to be in your library *load* path as well as your library
*link* path, which you set correctly.

Two workarounds suggest themselves:

1. Make sure your OS can find the library at load time.  On Linux for
example, you'd do this by setting the environment variable LD_LIBRARY_PATH
to include the path /usr/local/pgsql/lib before running your program.

2. Alternatively, create a link to libpq.so somewhere in your existing 
library load path so your system knows where to find it by default.  You
could call it /usr/local/lib/libpq.so, for instance.


Jeroen