views:

107

answers:

4
Error:  Can't load '/home/oracle/.cpan/build/DBD-Pg-2.16.1/blib/arch/auto/DBD/Pg/Pg.so' for module DBD::Pg: libpq.so.5: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm line 230.

Did anyone have similar error while instaling DBD::Pg perl module ? what can I do to fix it ?

A: 

The libpq.so.5 file is missing, which indicates that you do not have the Postgresql client library installed. On Ubuntu this file is provided by the libpq5 package.

Brian Showalter
I have it installed I can manually locate libpq.so and all permissions are right
Gandalf StormCrow
+1  A: 

You should go under perl to solve these dynamic linking problems. Use strace program &> out, and then grep for libpq.so.5. My guess is your libpq.so.5 is in the wrong location, or your DynaLoader is misconfigured. Read the docs on @dl_library_path.

You can see what your search path is with this (the strace will also show it trying to find the .so by checking each directory):

perl -MDynaLoader -le'print for @DynaLoader::dl_library_path;'

Make sure your libpq.5.so falls in one of those. The strace will also show if the kernel is returning an error to DynaLoader that it is cloaking; moreover, it will certainly tell you everything DynaLoader knows.

Evan Carroll
A: 

Make sure the path to the PostgreSQL library is in either ld.so.conf or in a file in ld.so.conf.d and re-run "sudo ldconf" (or sudo /sbin/ldconf). That's taken care of this issue when I've encountered it in the past.

Matthew Wood
A: 

I know lots of people have answered your question but I thought I'd add one more thing. Makefile.PL locates the postgres libraries by executing pg_config. If this can't be found on your path, then you will find this sort of error. Interestingly though, it looks for the headers in the same way. Try running pg_config from your terminal and see what the output is. If it's not found in your path, locate it, add to your path and try to build DBD::Pg again

Nic Gibson