deMize has asked for the wisdom of the Perl Monks concerning the following question:

These are the steps I took:
1) Installed Perl 5.10 from ActiveState (http://www.activestate.com/activeperl/)
2) Installed PostgreSQL v8.4 using Enterprise DB one-click installer (http://www.enterprisedb.com/products/pgdownload.do#windows)
3) Installed Apache HTTP Server v2.2.13 (http://httpd.apache.org/)

All of these are up and running correctly; tested Perl programs, loaded/queried tables in Postgres, and can access pages using http://localhost. Postgres and Perl were installed to C:\Program Files and Apache is on a different partition.

I added a bunch of repositories and installed DBD::Pg using the ActivePerl PPM - everything seemed to be fine, but when I go to connect to Postgres, I'm getting a weird error.

This is the error I get:
install_driver(Pg) failed: Can't load 'C:/Program Files/Perl/site/lib/ +auto/DBD/Pg/Pg.dll' for module DBD::Pg: load_file:The specified modul +e could not be found at C:/Program Files/Perl/lib/DynaLoader.pm line +201. at (eval 8) line 3

I tried installing from the command prompt "cpan> install DBD::Pg", but I get weird errors like the libpq not installed, when libpq.dll does exist. Windows sucks @ installing open source stuff (or I just suck at installing it). I know my script works, because I use it on a Linux box.

I would sure like assistance if anyone could give it. I think I had this working in the past, but that was when I installed the programs to the default directories (not Program Files).

Result of trying to run from cpan command line:
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\vol7ron>perl cpan Can't open perl script "cpan": No such file or directory C:\Documents and Settings\vol7ron>cpan Set up gcc environment - 3.4.5 (mingw-vista special r3) cpan shell -- CPAN exploration and modules installation (v1.9402) Enter 'h' for help. cpan> install DBD::Pg Fetching with LWP: http://ppm.activestate.com/CPAN/authors/01mailrc.txt.gz Going to read 'C:\Program Files\Perl\cpan\sources\authors\01mailrc.txt +.gz' ...................................................................... +......DONE Fetching with LWP: http://ppm.activestate.com/CPAN/modules/02packages.details.txt.gz Going to read 'C:\Program Files\Perl\cpan\sources\modules\02packages.d +etails.txt .gz' Database was generated on Fri, 04 Sep 2009 09:27:08 GMT ...................................................................... +......DONE Fetching with LWP: http://ppm.activestate.com/CPAN/modules/03modlist.data.gz Going to read 'C:\Program Files\Perl\cpan\sources\modules\03modlist.da +ta.gz' ...................................................................... +......DONE Going to write C:\Program Files\Perl\cpan\Metadata Running install for module 'DBD::Pg' Running make for T/TU/TURNSTEP/DBD-Pg-2.15.1.tar.gz Fetching with LWP: http://ppm.activestate.com/CPAN/authors/id/T/TU/TURNSTEP/DBD-Pg-2.15 +.1.tar.gz Fetching with LWP: http://ppm.activestate.com/CPAN/authors/id/T/TU/TURNSTEP/CHECKSUMS Checksum for C:\Program Files\Perl\cpan\sources\authors\id\T\TU\TURNST +EP\DBD-Pg- 2.15.1.tar.gz ok Scanning cache C:\Program Files\Perl/cpan/build for sizes DONE DBD-Pg-2.15.1/ DBD-Pg-2.15.1/quote.h DBD-Pg-2.15.1/.perlcriticrc DBD-Pg-2.15.1/TODO DBD-Pg-2.15.1/README DBD-Pg-2.15.1/types.c DBD-Pg-2.15.1/Changes DBD-Pg-2.15.1/Makefile.PL DBD-Pg-2.15.1/t/ DBD-Pg-2.15.1/t/00basic.t DBD-Pg-2.15.1/t/08async.t DBD-Pg-2.15.1/t/01constants.t DBD-Pg-2.15.1/t/03smethod.t DBD-Pg-2.15.1/t/01connect.t DBD-Pg-2.15.1/t/03dbmethod.t DBD-Pg-2.15.1/t/06bytea.t DBD-Pg-2.15.1/t/02attribs.t DBD-Pg-2.15.1/t/04misc.t DBD-Pg-2.15.1/t/lib/ DBD-Pg-2.15.1/t/lib/App/ DBD-Pg-2.15.1/t/lib/App/Info.pm DBD-Pg-2.15.1/t/lib/App/Info/ DBD-Pg-2.15.1/t/lib/App/Info/RDBMS/ DBD-Pg-2.15.1/t/lib/App/Info/RDBMS/PostgreSQL.pm DBD-Pg-2.15.1/t/lib/App/Info/Util.pm DBD-Pg-2.15.1/t/lib/App/Info/Request.pm DBD-Pg-2.15.1/t/lib/App/Info/Handler.pm DBD-Pg-2.15.1/t/lib/App/Info/Handler/ DBD-Pg-2.15.1/t/lib/App/Info/Handler/Prompt.pm DBD-Pg-2.15.1/t/lib/App/Info/RDBMS.pm DBD-Pg-2.15.1/t/dbdpg_test_setup.pl DBD-Pg-2.15.1/t/20savepoints.t DBD-Pg-2.15.1/t/07copy.t DBD-Pg-2.15.1/t/09arrays.t DBD-Pg-2.15.1/t/00-signature.t DBD-Pg-2.15.1/t/12placeholders.t DBD-Pg-2.15.1/t/99cleanup.t DBD-Pg-2.15.1/dbivport.h DBD-Pg-2.15.1/Pg.h DBD-Pg-2.15.1/dbdimp.c DBD-Pg-2.15.1/quote.c DBD-Pg-2.15.1/META.yml DBD-Pg-2.15.1/lib/ DBD-Pg-2.15.1/lib/Bundle/ DBD-Pg-2.15.1/lib/Bundle/DBD/ DBD-Pg-2.15.1/lib/Bundle/DBD/Pg.pm DBD-Pg-2.15.1/Pg.xs DBD-Pg-2.15.1/README.win32 DBD-Pg-2.15.1/win32.mak DBD-Pg-2.15.1/MANIFEST DBD-Pg-2.15.1/SIGNATURE DBD-Pg-2.15.1/Pg.pm DBD-Pg-2.15.1/MANIFEST.SKIP DBD-Pg-2.15.1/README.dev DBD-Pg-2.15.1/dbdimp.h DBD-Pg-2.15.1/types.h CPAN.pm: Going to build T/TU/TURNSTEP/DBD-Pg-2.15.1.tar.gz Set up gcc environment - 3.4.5 (mingw-vista special r3) Configuring DBD::Pg 2.15.1 Path to pg_config? c:\Program Files\PostgreSQL\8.4\bin\pg_config.exe PostgreSQL version: 80400 (default port: 5432) POSTGRES_HOME: (not set) POSTGRES_INCLUDE: c:/PROGRA~1/POSTGR~1/8.4/include POSTGRES_LIB: c:/PROGRA~1/POSTGR~1/8.4/lib OS: MSWin32 *** Warning: whitespace characters in the current directory path (C:/P +rogram Fil es/Perl/cpan/build/DBD-Pg-2.15.1-9RDqNH) may cause problems Checking if your kit is complete... Looks good Unable to find a perl 5 (by these names: C:\Program Files\Perl\bin\per +l.exe perl .exe perl5.exe perl5.10.1.exe miniperl.exe, in these dirs: . C:\Progra +m Files\Pe rl\site\bin C:\Program Files\Perl\bin C:\Perl\site\bin C:\Perl\bin C:\ +WINDOWS\sy stem32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\Program Files\QuickTime\ +QTSystem\ C:\WINDOWS\system32\WindowsPowerShell\v1.0 C:\Program Files\Microsoft +SQL Server \90\Tools\binn\ C:\Program Files\Perl\bin) Note (probably harmless): No library found for -lpq Using DBI 1.607 (for perl 5.010001 on MSWin32-x86-multi-thread) instal +led in C:/ Program Files/Perl/lib/auto/DBI/ Writing Makefile for DBD::Pg ========================================================== WARNING! No libpq libraries were detected! You need to install the postgresql-libs package for your system, or set the POSTGRES_LIB environment variable to the correct place. Removing (Makefile) =========================================================== Warning: No success on command["C:\Program Files\Perl\bin\perl.exe" Ma +kefile.PL INSTALLDIRS=site] TURNSTEP/DBD-Pg-2.15.1.tar.gz "C:\Program Files\Perl\bin\perl.exe" Makefile.PL INSTALLDIRS=site -- + NOT OK Running make test Make had some problems, won't test Running make install Make had some problems, won't install Failed during this command: TURNSTEP/DBD-Pg-2.15.1.tar.gz : writemakefile NO '"C:\ +Program Fi les\Perl\bin\perl.exe" Makefile.PL INSTALLDIRS=site' returned status 2 +56

Replies are listed 'Best First'.
Re: Installing DBD::Pg on Windows XP Pro 32b
by syphilis (Archbishop) on Sep 06, 2009 at 01:22 UTC
    install_driver(Pg) failed: Can't load 'C:/Program Files/Perl/site/lib/auto/DBD/Pg/Pg.dll' for module DBD::Pg: load_file:The specified module could not be found at C:/Program Files/Perl/lib/DynaLoader.pm line 201.
    at (eval 8) line 3


    The Pg.dll mentioned in the error message can't load because it needs another dll (probably the PostgreSQL dll), and it can't find that dll.
    The solution could be as simple as adding the location of that dll to the path.

    Often, such error messages are accompanied by a pop-up that tells you the name of the dll that can't be found. Did you get such a pop-up box ?

    Cheers,
    Rob
      I didn't get any pop-up during the install. I used ActiveState's PPM to install it, and it said it completed successful.

      The error was produced when I ran my cgi script, calling DBI->connect()

      In ~\site\lib\auto\DBD\Pg there is:
      .packlist Pg.bs Pg.dll Pg.exp Pg.lib Pg.pdb
      I've added the following libraries to the post-following directories:
      comerr32.dll gssapi32.dll k5sprt32.dll krb5_32.dll libeay32.dll libiconv2.dll libintl3.dll libpq.dll ssleay32.dll
      Directories:
      c:\Windows c:\Windows\System32 c:\Program Files\PostgreSQL\8.4\bin c:\Program Files\Perl\site\lib\auto\DBD\Pg


      I tried looking into DynaLoader, but didn't traverse it that well -- hoping someone else already had this problem (and a solution).
Re: Installing DBD::Pg on Windows XP Pro 32b
by ikegami (Patriarch) on Sep 06, 2009 at 18:05 UTC
    I keep geting a popup complaining about libpq.dll not being found. Adding c:\progs\PostgreSQL\8.4\lib to the path got me past that error and complained about ssleay32.dll instead. Rince and repeat, I suppose. I didn't go any further.
      Where did you set the library? In the makefile.pl? I think it's pointing to the correct place?
        I added it to the path
Re: Installing DBD::Pg on Windows XP Pro 32b
by lamprecht (Friar) on Sep 06, 2009 at 18:42 UTC
      Yeah I think camelbox has one too, I've invested so much time that I'd like to get this to work now.

      I feel like the libpq was the major problem to begin with and that "Program Files" might not have been a problem. The question is how do I fix this using ikegami's method.

      I still get the error and I tried manually setting the $ENV{POSTGRES_LIB} variable as well as the other ones in MAKEFILE.pl, to no luck. I think I'm going to start asking for filenames and line numbers :(
Re: Installing DBD::Pg on Windows XP Pro 32b
by erix (Prior) on Sep 07, 2009 at 12:16 UTC
Re: Installing DBD::Pg on Windows XP Pro 32b
by Limbic~Region (Chancellor) on Nov 03, 2009 at 00:38 UTC
    deMize,
    The solution was simple for me. Go into control panel, system, advanced, environment variables. Then, modify PATH to include the path to the Pg bin directory. It is misleading to think you need to add the lib dir, but that's all it took for me.

    Cheers - L~R