views:

3711

answers:

6

PHP 5.2.8 is refusing to load php_pgsql.dll, with the following error:

Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php_pgsql.dll' - The specified module could not be found.

in Unknown on line 0

The .dll exists in PHP/ext/.

Has anyone else had this problem with PHP on Windows before?

A: 

The only time I've seen this error (and the file name and ext path were definitely correct) was when I tried using an incorrect version of the DLL ie. I used one that was compiled against a different version of PHP to the one I was running.

Make sure your version is definitely the one compiled against PHP 5.2.8.

Edit: or, the permissions on the file were set incorrectly.

Jack Sleight
The permissions are fine and this is the dll I got with the PHP download so I assume it's compiled for the correct version. Any way I can check that?
Ross
Hmmm, if it's the one that came with the download it should be fine. Sorry, out of ideas :-( .
Jack Sleight
+3  A: 

The problem is with the related libraries used by php_pgsql.dll - like libpq.dll, the OpenSLL ones etc. You need to find them (from the zip distribution of Postgres, from an installed psqlODBC driver etc.) and put them in a folder which is in the PATH. As for the list of all DLLs - use MS Dependency Walker (depends.exe).

Another important bit - Apache (if you use Apache that is) has its own set of OpenSSL DLLs. Replace or just rename those so to not clash with those from the Postgres distribution.

Milen A. Radev
Sounds complex - but when I run a PHP -v from the command line it does throw an error saying libpq.dll couldn't be loaded. I may just move all my development to the ubuntu box tbh.
Ross
A: 

I have same problem on PHP 5.2.9 on windows/apache2.2. I tried Dependency Walker, all required dlls are in the system.

Dependency Walker finds only static linked dlls. if the driver is loading dynamic the dlls, you cant see it.
Bernd Ott
A: 

LIBPQ.DLL problem with php on Vista...

  • Check to make sure you actually have postgres installed. If you install php on windows with postgres API, without postgres being installed, you may get this warning. It's too easy to just click everything on the Windows installer...

  • Comment out the relevant line in php.ini.

A: 

Just a thought -- make sure that the Postgres binaries are in the SYSTEM path, not your user-specific path. As it happens, that was the problem on my machine. :-)

Edit:

Come to think of it, that explains why Dependency Walker would report all A-OK but the problem would still persist -- you run DW under your own account, while Apache runs as SYSTEM, and hence won't have your personal PATH settings available.

Rytmis
+1  A: 

Check out the info on the PHP PostgreSQL installation page: http://us.php.net/manual/en/pgsql.installation.php

"On a Windows server, configured with Apache, adding the following line to httpd.conf to load libpq.dll can save you a lot of time :

LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"

Note that you will have to change your folder accordingly to the installation path and version of PostgreSQL you have installed. Also note that having Apache and PostgreSQL on the same server for production environments is not recommended.

Cheers, Serjik"

This fixed my setup instantly.

Mac
Now THAT actually worked
Stanislav Palatnik