error while loading shared libraries: libpq.so.3
i have written a program sample.c
it is as folllows:
#include<stdlib.h>
#include<libpq-fe.h>
int main()
{
PGconn *myconnection = PQconnectdb("");
printf("Hi");
return 0;
}
I then compile this program using makefile
make sample
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
Please tell what the problem is..and how should I rectify it?
On Mon, Feb 21, 2005 at 12:47:58PM +0530, Surabhi Ahuja wrote:
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
You probably need to specify a runtime library search path option
like -R or -rpath (see your compiler or linker documentation). For
example, the following might work:
cc -L/usr/local/pgsql/lib -R/usr/local/pgsql/lib ...
See also the manual page for the ldd command if your system has it.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
On Mon, 21 Feb 2005 06:17 pm, Surabhi Ahuja wrote:
i have written a program sample.c
it is as folllows:
#include<stdlib.h>
#include<libpq-fe.h>
int main()
{
PGconn *myconnection = PQconnectdb("");
printf("Hi");
return 0;
}I then compile this program using makefile
make sample
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
Please tell what the problem is..and how should I rectify it?
Your library is in /usr/local/pgsql/lib this is obviously not in your ld.so.conf
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sample
Regards
Russell Smith.
I give the following command now to compile sample.c
gcc -o sample sample.c -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -rpath/usr/local/pgsql/lib - lpq
it gives this message:
gcc: unrecognized option `-rpath/usr/local/pgsql/lib'
(the same happens if i give -R instaed of -rpath
________________________________
From: Michael Fuhr [mailto:mike@fuhr.org]
Sent: Mon 2/21/2005 12:55 PM
To: Surabhi Ahuja
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] error while loading shared libraries: libpq.so.3
***********************
Your mail has been scanned by InterScan VirusWall.
***********-***********
On Mon, Feb 21, 2005 at 12:47:58PM +0530, Surabhi Ahuja wrote:
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
You probably need to specify a runtime library search path option
like -R or -rpath (see your compiler or linker documentation). For
example, the following might work:
cc -L/usr/local/pgsql/lib -R/usr/local/pgsql/lib ...
See also the manual page for the ldd command if your system has it.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Import Notes
Resolved by subject fallback
it now says:
i do the following
make sample
LDLIBRARY = /usr/local/pgsql/lib ./sample
LDLIBRARY: Command not found.
________________________________
From: Russell Smith [mailto:mr-russ@pws.com.au]
Sent: Mon 2/21/2005 2:19 PM
To: Surabhi Ahuja
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] error while loading shared libraries: libpq.so.3
***********************
Your mail has been scanned by InterScan VirusWall.
***********-***********
On Mon, 21 Feb 2005 06:17 pm, Surabhi Ahuja wrote:
i have written a program sample.c
it is as folllows:
#include<stdlib.h>
#include<libpq-fe.h>
int main()
{
PGconn *myconnection = PQconnectdb("");
printf("Hi");
return 0;
}I then compile this program using makefile
make sample
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
Please tell what the problem is..and how should I rectify it?
Your library is in /usr/local/pgsql/lib this is obviously not in your ld.so.conf
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sample
Regards
Russell Smith.
Import Notes
Resolved by subject fallback
On Mon, 21 Feb 2005 08:05 pm, Surabhi Ahuja wrote:
it now says:
i do the following
make sample
LDLIBRARY = /usr/local/pgsql/lib ./sampleLDLIBRARY: Command not found.
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sample
Note there is no SPACE in the example I have given.
LDLIBRARY=/usr/local...
NOT
LDLIBRARY = /usr/...
Regards
Russell Smith.
Show quoted text
________________________________
From: Russell Smith [mailto:mr-russ@pws.com.au]
Sent: Mon 2/21/2005 2:19 PM
To: Surabhi Ahuja
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] error while loading shared libraries: libpq.so.3***********************
Your mail has been scanned by InterScan VirusWall.
***********-***********On Mon, 21 Feb 2005 06:17 pm, Surabhi Ahuja wrote:
i have written a program sample.c
it is as folllows:
#include<stdlib.h>
#include<libpq-fe.h>
int main()
{
PGconn *myconnection = PQconnectdb("");
printf("Hi");
return 0;
}I then compile this program using makefile
make sample
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
Please tell what the problem is..and how should I rectify it?Your library is in /usr/local/pgsql/lib this is obviously not in your ld.so.conf
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sampleRegards
Russell Smith.
mr-russ@pws.com.au (Russell Smith) writes:
On Mon, 21 Feb 2005 08:05 pm, Surabhi Ahuja wrote:
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sampleNote there is no SPACE in the example I have given.
LDLIBRARY=/usr/local...NOT
LDLIBRARY = /usr/...
Regards
Shouldn't that be LD_LIBRARY_PATH?
--
Remove -42 for email
On Mon, Feb 21, 2005 at 02:22:20PM +0530, Surabhi Ahuja wrote:
I give the following command now to compile sample.c
gcc -o sample sample.c -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -rpath/usr/local/pgsql/lib - lpqit gives this message:
gcc: unrecognized option `-rpath/usr/local/pgsql/lib'
(the same happens if i give -R instaed of -rpath
As I said, see your compiler or linker documentation for the correct
option. Another possibility might be "-Wl,-rpath=/usr/local/pgsql/lib",
but *see the documentation* instead of using trial-and-error.
What's happening is that the run-time linker doesn't know where to
find libpq. You can fix that a few different ways:
1. You can add run-time link information when you build the program.
That's what the aforementioned options are for; see your documentation
to find out the correct way to do it. Some people consider this the
"right" way to solve the problem.
2. You can globally change the run-time linker's configuration.
How to do this depends on the platform, so again, you'll have to
consult your local documentation.
3. You can use an environment variable like LD_LIBRARY_PATH to tell
the run-time linker what additional directories to search. Many
people consider this a workaround rather than a fix and therefore
suggest avoiding it in favor of (1) or possibly (2).
http://www.visi.com/~barr/ldpath.html
NOTE: This is a build procedure issue that has nothing to do with
PostgreSQL, aside from the fact that in this particular case you're
trying to link against a PostgreSQL library. You'll have the same
problem any time you link against a shared library that's not in
the run-time linker's path.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Russell Smith wrote:
On Mon, 21 Feb 2005 08:05 pm, Surabhi Ahuja wrote:
it now says:
i do the following
make sample
LDLIBRARY = /usr/local/pgsql/lib ./sampleLDLIBRARY: Command not found.
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sampleNote there is no SPACE in the example I have given.
LDLIBRARY=/usr/local...NOT
LDLIBRARY = /usr/...
Regards
Russell Smith.
________________________________
From: Russell Smith [mailto:mr-russ@pws.com.au]
Sent: Mon 2/21/2005 2:19 PM
To: Surabhi Ahuja
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] error while loading shared libraries: libpq.so.3***********************
Your mail has been scanned by InterScan VirusWall.
***********-***********On Mon, 21 Feb 2005 06:17 pm, Surabhi Ahuja wrote:
i have written a program sample.c
it is as folllows:
#include<stdlib.h>
#include<libpq-fe.h>
int main()
{
PGconn *myconnection = PQconnectdb("");
printf("Hi");
return 0;
}I then compile this program using makefile
make sample
cc -I/usr/local/pgsql/include sample.c -L/usr/local/pgsql/lib -lpq -o sample
I then run it....and it gives and error
[indra:/homes/surabi] ./sample
./sample: error while loading shared libraries: libpq.so.3: cannot open shared object file: No such file or directory
Please tell what the problem is..and how should I rectify it?Your library is in /usr/local/pgsql/lib this is obviously not in your ld.so.conf
do you still experience problems when you run
LDLIBRARY=/usr/local/pgsql/lib ./sampleRegards
Russell Smith.
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
Russell,
Does it help if you execute the following?
LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH
PATH=/usr/local/pgsql/bin:$PATH
export PATH
good luck,
Phil