Thread: C interface libpq.so.2 problem

C interface libpq.so.2 problem

From
dsmclennan@spipowernet.com.au
Date:
Hi ,

as a new user I have followed the Momjian libpq sample program format

#include "libpq-fe.h"

and cc -I/usr/local/pgsql/include -o myapp myapp.c
-L/usr/local/pgsql/lib -lpq

my application compiles but on execution gives

libpq.so.2: cannot open shared object file

Similar problems have been listed before but none of the suggestions fixed
my problem.
Does anyone recognise this problem?

Thanks

David McLennan



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



Re: C interface libpq.so.2 problem

From
Andreas Kretzer
Date:
<tt>dsmclennan@spipowernet.com.au schrieb:</tt><blockquote type="CITE"><tt>Hi ,</tt><p><tt>as a new user I have
followedthe Momjian libpq sample program format</tt><p><tt>#include "libpq-fe.h"</tt><p><tt>and cc
-I/usr/local/pgsql/include-o myapp myapp.c</tt><br /><tt>-L/usr/local/pgsql/lib -lpq</tt><p><tt>my application compiles
buton execution gives</tt><p><tt>libpq.so.2: cannot open shared object file</tt><br /> </blockquote><tt>This looks like
aninstallation problem! Your program is ok, but</tt><br /><tt>when it tries to load the libpq.so it fails. The idea of
theshared</tt><br /><tt>objects (that is what .so means; like the DLL in wind*ws) is to</tt><br /><tt>have a library in
aspecific version and use an _unspecific_ name</tt><br /><tt>for it.</tt><p><tt>So the library libpq.so is a symbolic
linkto libpq.so.<major> and</tt><br /><tt>this one could / should be a link to
libpq.so.<major>.<minor>where</tt><br /><tt><major> and <minor> refer to the concrete version
ofthe library.</tt><p><tt>It looks, like your lipq.so is a symbolic link to a nonexistent</tt><br /><tt>library
libpq.so.2(or that file may have unsufficient rights).</tt><br /><tt>Perhaps it's best you check your files; and make
shurethat you are</tt><br /><tt>looking at the right ones. The libraries are searched according to</tt><br /><tt>the
entriesin /etc/modules.conf (after changing this file a</tt><br /><tt>ldconfig is needed).</tt><p><tt>Newer Postgres
versions(or maybe all versions that you compile</tt><br /><tt>yourself) install their libraries under
/usr/local/pgsql/lib.</tt><br/><tt>Maybe you had older versions directly from your distribution</tt><br /><tt>in
/usr/libor /usr/i486-linux-libc5/lib or</tt><br /><tt>/usr/i486-linux-libc6/lib. In this case all depends on
the</tt><br/><tt>searchpath for the libraries.</tt><p><tt>You can use 'ldd yourprogram' to find out, which libraries
it</tt><br/><tt>depends on. If your program doesn't directly need the libpq.so</tt><br /><tt>you can check out all
librariesit uses for their dependencies.</tt><p><tt>Arrrgh, STOP! I just recognized, that some programs/libs
directly</tt><br/><tt>require the libpq.so.2 (not just the generic name libpq.so). If</tt><br /><tt>this is the case
withyour program, it seems that you just don't</tt><br /><tt>have any libpq.so on your system or forgot to write the
library-</tt><br/><tt>path into the above mentioned file /etc/modules.conf (on older</tt><br /><tt>systems there was a
/etc/conf.modules- so check this out).</tt><p><tt>Hope this helps</tt><p><tt>Andreas</tt>