PHP Windows install: Unable to load dynamic library php_mssql.dll, php_pspell.dll etc
Posted on 13 July 2009
After you install a default PHP 5.0.x – 5.3.x on a standard Apache 2.0 or 2.2 or Internet Information Services on Windows you get numerous “PHP Warning: PHP Startup: Unable to load dynamic library ‘c:\\php_path\\ext\\php_libname.dll’ — The specified module could not be found. in Unknown on line 0“. Great! Starting out on a fresh install and things just don’t work well. Looking up the filenames of these dlls, you’ll see that they’re all available in the right directory. So what’s the problem?
Quite likely, you leave the warnings as they are because most things just work with PHP, or you disable some of the extensions in php.ini and you’re not bothered with it anymore. This is a bug with PHP as long as I know it and it annoys me a lot that nobody ever bothered to even try a default install and check whether it worked problem-free. This article explains how you can get rid of these errors. It is not much work, but be prepared to spend about half an hour at least.
What happens when you install PHP with all defaults
You download a full package, leave everything on and then click Install. It is the most basic configuration. After which you get all of the following errors in either your log or on the DOS prompt when you run it from the console:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_mssql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_oci8.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_openssl.dll' - The operating system cannot run %1.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pdo_mssql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pdo_oci.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pdo_oci8.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pdo_sqlite_external.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_pspell.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\PHP5.2\\ext\\php_sybase_ct.dll' - The specified module could not be found.\r\n in Unknown on line 0
When you run the command PHP from the command line, you get to see the same warning and on top of that you get many popups of libraries that cannot be found.
All these files are available on the said locations, so what’s this “The module could not be found” all about? Placing the libraries in the PHP root directory obviously doesn’t work. Going to the php.ini and changing the settings for each and everyone of these to not load them helped, but that isn’t really a solution. So you google a bit. Just googling for the first line only already gives many PHP bug hits and other then a lot of babble, none of these offer a serious solution. Due to the tedious PHP bug system, bugs are considered “closed” when there’s a week of inactivity, which may come in handy for keeping the system clean, but also results in many bugs unresolved and repeated submission from the same bugs.
When I first encountered this problem, 2 years ago, I managed to solve it by changing the installation to only include the extensions for mysql, but that’s not really a good solution if you need some of the others, like OCI, P-Spell, Sybase or OpenSSL. Some of the manual sites have notes on this issue with partial resolutions in an English comment: in French, Hungarian and Brasilian Portugese does so too. These are all doubles (don’t bother to look them up) which won’t lead to a full resolution.
Cause: certain libraries are not installed
When you first install PHP with all defaults set, some of the libraries cannot be installed. Either because the necessary files are not in the MSI package (they are in the ZIP package, see below) or because some extensions need libraries that are part of larger distributions or are not licensed under the GPL.
The following section describes how you can analyze these errors yourself. This can be useful if you have similar errors, but for different libraries, or when the steps below do not remedy your situation.
The errors you see are deceptive. It mentions a filename and then it says “the specified module could not be found”. The module is there, so the error seems wrong. What next? I started the Process Monitor from SysInternals to analyze what was going on under the hood to find out what file could not be found.
Quick solution: do not load the extensions
In the next solution, I present a way to use all these extensions without errors. But as you will find out, apart from three or four of them, this is quite a bit of work. If you do not need these extensions, you don’t have to turn them on. However, if you do need Oracle, Microsoft SQL Server or SQLite connectivity, SSL access or the p-spell spelling control, you’ll have to take the long road.
Locate the following lines and place a comma in front of them (use search in your editor, it’s usually near or at the bottom, ordered mostly alphabetically):
[PHP_OCI8] ; extension=php_oci8.dll [PHP_OPENSSL] ; extension=php_openssl.dll [PHP_PDO_OCI] ; extension=php_pdo_oci.dll [PHP_PDO_OCI8] ; extension=php_pdo_oci8.dll [PHP_PDO_PGSQL] ; extension=php_pdo_pgsql.dll [PHP_PDO_SQLITE] ; extension=php_pdo_sqlite.dll [PHP_PDO_SQLITE_EXTERNAL] ; extension=php_pdo_sqlite_external.dll [PHP_SQLITE] ; extension=php_sqlite.dll [PHP_SYBASE_CT] ; extension=php_sybase_ct.dll
Solution: install the missing libraries
As the previous section showed, the files mentioned are not the ones that are gone. Instead, the message seems to say “Hey, I’m php_mssql.dll, but I cannot find something, I’m not gonna tell you what that is, but I’m just gonna end myself with a useless and confusing error. Bye bye!”. If this were a commercial package, I would ask my money back. But because this is a community effort, I can understand that in six years of development nobody of the thousands of testers have ever tried to do a normal installation with all settings set to default. Well, why would you, after all, none of the noobs would ever use the defaults, right? But that’s going to change as I’m about to bug them each month or so with a link to this post to tell them how to fix it, because I was one of those noobs that didn’t see the hidden instruction that said “remove all extensions in the setup and then click only very sparingly some extensions that maybe are in this distribution, possibly, if you are lucky”.
Enough babble on the subject of sneering. As some posts have shown, it is already quite a help if you install the ZIP package isntead of the MSI and then follow these instructions. But that’s not enough. It will remove three of the 11 messages you receive on a 5.2.x installation (even more on the 5.1 and 5.0 installations). So, I did some homework for you to make this easy. Here’s for each package that you can select in the installation but that does not install correctly (yes, that’s about almost every package!) what you can do to resolve it:
Listing per module of missing libraries
The following table lists all the missing libraries that a typical default installation on Windows Vista encountered. The list with wrong versions may be different for you. If you’ve installed some of these on an earlier encounter you may not have the same errors. But the basic method for resolution is the same: add the missing libraries and copy (not move!) the libraries with a wrong version to the base directory of the extensions.
module |
missing library |
wrong version |
description of problem |
php_mssql.dll |
ntwdblib.dll | available inside ZIP package of PHP | |
php_oci8.dll |
oci.dll | see text | |
php_openssl.dll |
libeay32.dll, ssleay32.dll | wrong version of libeay32.dll in system32 dir | |
php_pdo_mssql.dll |
ntwdblib.dll | available inside ZIP package of PHP | |
php_pdo_oci.dll |
oci.dll | see text | |
php_pdo_oci8.dll |
oci.dll | see text | |
php_pdo_pgsql.dll |
libpq.dll | ssleay32.dll | wrong version of ssleay32.dll in system32 dir |
php_pdo_sqlite_external.dll |
sqlite3.dll | must be downloaded | |
php_pgsql.dll |
libpq.dll |
ssleay32.dll | available inside ZIP package of PHP, but then still wrong version of ssleay32.dll in system32 dir |
php_pspell.dll |
aspell-15.dll | available inside ZIP package of PHP | |
php_sybase_ct.dll** |
libcs.dll, libct.dll | see text (libct.dll only showed up in dep. walker, not in the process monitor) |
Step by step instruction
To get all modules working, just follow three simple steps (may take a while to finish up though):
- The green bold marked libraries are inside the ZIP package of the Windows PHP distribution. Download this ZIP package (must match the version you have of the MSI installer!) and simply copy these three libraries to the PHP root directory.
- The red bold libraries are not available in the ZIP package and are not part of the MSI distribution. In fact, apart from
sqlite3.dll, these dlls require special installation. See the section on each file. - The red cursive bold libraries (third column) may or may not give errors on your system, it depends on whether you have other Open SSL libraries installed that already used earlier versions. If these files are inside the
c:\windows\system32directory, either replace them with the new version from your PHP directory or copy these two libraries to theapache\bindirectory.
About files in the ZIP distribution
Not all files are delivered with the MSI installer. The green dlls in the list above are all available through the ZIP distribution. Go to the PHP Download page and locate the ZIP distribution that matches your current PHP version. Simply copy these libraries to the php base directory.
About wrong version of libeay32.dll and ssleay32.dll
The totally un-understandable error that Apache shows — on behalf of PHP — that belongs to an extension trying to load another dll which appears to be of the wrong version:
PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\\PHP52\\ext\\php_pgsql.dll’ – The operating system cannot run %1.\r\n in Unknown on line 0
Though the correct version is installed inside the PHP directory, the extensions are not correctly looking there, instead, they look in their base directories. Because they are loaded by Apache, the base directory is ApacheDir\bin, which is not where these libraries are. In fact, the order in which libraries are searched is:
%apache_home%\bin%windir%\system32%windir%\system%windir%%apache_home%%php_home%- everything in the
%path%
As far as I know, it is not possible to modify this order (for instance, it shouldn’t be too hard to add a preferred dll search path in the php.ini on a per-extension basis). In my case, the ssleay32.dll and the libeay32.dll files with a version from the year 2007, were found in the system32 directory. Since this is about the first directory that is searched, there are only two solutions here:
Solution 1: copy the correct dll from %php_home% to the %apache_home%\bin directory
Updating the %apache_home%\bin directory has the advantage of keeping everything closer together, in the case of moving the website to another system, this is easier.
Solution 2: update the dll in the system32 directory with a more recent one.
Normally, these files are backward compatible as long as their names do not change. In this case, it would be quite safe to update the files in the system32 directory.
About downloading oci.dll
It won’t work to simply download only oci.dll from some site (you can download it from several). The file oci.dll is part of the Oracle C Interface. Unless you need to use Oracle, I suggest you go to the relevant line inside the php.ini file and uncomment the loading of this extension. However, if you need to use this extension, you’ll need to install the free Oracle Client libraries and add them to the path. It is a bit more involved then that, though, but Oracle has a nice article describing how to install PHP and the Oracle Instant Client on Linux or Windows.
About downloading sqlite3.dll
The most recent version of sqlite3.dll can always be found on the SQLite download page, where a small zip package with a precompiled dll version for Windows is available. For convenience, I made the sqlite3.dll available for download as well, just place it in the root of your PHP installation.
About downloading libcs.dll and libct.dll
These dlls are part of the Sybase ASE distribution. The Sybase issue is very old and was already submitted in 2001 with PHP 4.0 but not resolved.
The files libcs.dll and libct.dll cannot be offered through Open Source canals because they are not available as Open Source. If you need interaction with a Sybase Adaptive Server, you should check the installation for the Open Client tools, which are part of the Adaptive Server Enterprise License.
I’m not certain whether it is possible to connect to Sybase legally with these dlls when you do not have a license. Sybase does support Open Source efforts that need connectivity to their servers, but the SDK only comes licensed with the paid packages. It seems odd to me that you need a license of the SDK to use tools that are developed with that SDK. I’d find it normal if dlls come in a redistributable version, just like with Microsoft’s SDK’s: once you develop your tool you can distribute the needed dlls as part of your application. If I find such a way, I’ll update this post.
Conclusion
Hope this helped you the way it helped me. I’m not a PHP specialist (I can program in it, but that doesn’t make me a specialist), but this problem should be solvable by any non-PHP programmer. Network administrators and system administrators will encounter these problems and possibly hire somebody to get rid of these odd looking errors, or they’ll ban PHP altogether because they can’t get it installed the first time around.
I really like open source projects, but this little part of the PHP open source project has shown a years long negligence, maybe even decadence towards the vast group of Windows users that try to install PHP on Windows. These errors will go unnoticed sometimes simply because many people do not know where to look for errors after installation. But creating a clean environment right from a fresh installation is vital to success and should be taken seriously by the development team. Despite many efforts, the PHP community has not taken that leap yet.
Is this one of the reasons why so many people still frown upon PHP as a serious language? Possibly so but I don’t know. For me, it doesn’t add to the admiration I might have had for this environment but for some useful tools I just need to have it running (WordPress, WikiMedia software etc).
– Abel –
Don’t follow the advised on the TechNet, MS Connect and MSDN forums, they are time-consuming and don’t work if you have a newer version of .NET installed like .NET 4.0. Instead, read this and easily fix this hard-to-resolve error by simply changing one registry value. read article
Ever tried to shrink a volume? Ever wondered why you cannot shrink a volume smaller than half its size? Ever wondered what $MFTMirr is all about and what it’s doing in the middle of your drive? Or do you just want to get the biggest available free space and shrink your drive? Then this article is for you — read article
Have you ever received this error using Windows System Backup and Restore Center? Never managed to get rid of it or it mysteriously keeps coming back? Here’s a lightweight and easy solution — read article
39 responses to PHP Windows install: Unable to load dynamic library php_mssql.dll, php_pspell.dll etc
Leave a Response
Additional comments powered by BackType

Hello@Abel.. Nice solution you have provide…Thanks for this.. Here I share another article about this windows system32 dll error ..Author define details about dll missing problem..as like you…
.Hope it helps to other…
Hi!
Thank you, this post has helped me solve the problem.
My specific problem was with PostgreSQL and a message like ‘Could not find driver’.
Regards,
Hi,
can I cry yet? I have installed WampServer 2.2, which bundles PHP 5.3.8, on my work computer (XP Pro, v2002, SP3). It’s installed just fine, but I, too, have received the mysterious error. After much googling & copying of dll’s all over the computer, I’m still not having any luck. Here are where the files are:
ntwdblib.dll
/ext
ntwdblib.dll
php_mssql.dll
/system32
ntwdblib.dll
php_mssql.dll
msvcr71.dll
as you can see, I’ve copied just about every dll I can find to every folder mentioned on this page (ok, that’s a bit of an exaggeration), but at least the required files are in the required folders. but I still get the error message 4x, since I have both php_mssql & php_pdo_mssql enabled.
are there any other suggestions someone might make that could help? I’ve had previous version of wampserver & php work on the machine, but no luck with current versions.
- O8
Hi,
This information is very helpful! I tried copying the ssleay32.dll file from my php directory to the apache\bin directory. There was already a ssleap32.dll file in apache\bin, so I renamed it. After I did this apache would not start. We are trying to get pgsql working in a test installation of XAMPP.
Anne
I tried copying the libpq.dll that was in the ext folder under php to apache\bin and leaving the ssleay32.dll file alone. That appeared to fix the issue. Thanks so much for your guidance!
hi I am trying to run php_mssql.dll but it doesn’t work? what should I have to do?
You cannot run php_mssql.dll just like that, it’s not an executable like an *.exe file. This post is about having problems with loading the dlls. What are you trying to achieve?
I couldn’t load the mssql extension for months. I searched the ntwdblib.dll & I copied to the %windows/system% directory and worked!
Thanks to the author.
Thank You, Stanislav Stoqnov. You have solved my problem. I was just about to scrap my project and start over.
The msvcr71.dll was present in the MS SQL program files directory, but not in the system32 folder.
Thank you very much Abel for posting the detailed and step-by-step guide. I found that the search order was most interesting. Although not listed, your post helped me figure out the problem I was experiencing.
The system I was troubleshooting was Win 2008 R2 ENT, using IIS7.5 with PHP 5.2.17. I installed PHP using the web installer tool that comes with IIS7. (So much for an easy install…) The problem I had was a PHP startup error on php_mssql.dll unable to load. There were others but this was the one I needed. Obviously the php_mssql.dll was present in the ext folder as well as the ntwdblib.dll in the PHP root folder.
My solution ended up being the “msvcr71.dll” as “Stanislav Stoqnov” in the comments here pointed out. Adding this file to the C:\Windows\SysWOW64 directory solved the issue for me.
Thanks again!
thank you SO much for this – well explained and goes beyond the surface crap you get from google. thank you again
thanks for your indo
thank you my friend, from Argentina
After all this time, this article is still relevant. Thank you for the tips. I’m using Windows 7, 64 bit, installed using php-5.3.6-nts-Win32-VC9-x86.msi and am receiving the oci.dll error amongst others (before I reinstalled and disabled those extensions I didn’t need).
Thx a whole lot!!! i could finaly connect to pgsql after upgrading ti php5.2.17. I’m just going to post this link to all over the internet… could save live!!!
cheers
Thanks you very mush!!!!
This is the Fabulous site I have come across with very good step by step explanation.
Thanks again.
Hola a todos, ya he investigado en varias paginas y se me hizo interesante esta que ha muchos ha ayudado la informacion proporcioanda aqui,
asi que aqui les explico mi situacion:
Requiero conectarme a una base de datos de sql server que esta en un servidor asi que busque la forma de hacerlo con php
utilizo esta funcion mssql_connect(‘ip_servidor’,'usuario’,'password’);
tengo instalado xampp con php 5.3.5, Apache 2.0
Investigue sobre el tema y son necesarias las siguientes librerias, asi que las descargue:
php_mssql.dll:
la copie a C:/xampp/php/ext
y
ntwdblib.dll:
la copie a c:/windows/system32
en php.ini:
Asigne la ruta de las extensiones de php: extension_dir = “C:\xampp\php\ext”
Descomente la linea: extension = php_mssql.dll
Despues de esto reinicie el servicio de apache desde el panel de xampp y al reiniciar me aparece una ventana de alerta con este error:
PHP Startup: Unable to load dynamic library ‘C:xampp\php\ext\php_mssql.dll’ -No se puede encontrar el modulo especificado
y, Al actualizar el navegador me sale este error:
Fatal error: Call to undefined function mssql_connect() in C:\xampp\htdocs\….\conexion_sqlserver.php on line 3
algo que me preocupo es que segun lo que lei para la version 5.3.5 de php NO esta diponible php_mssql.dll, alguien me puede confirmar esto?
De antemano muchas gracias. Saludos a todos.
Hola Marina,
ya pudiste solucionar tu problema?
tambien yo lo tengo, pero no he podido
Uso windows 2008 server, php 5.2.17 y apache 2.2.19
Me podrías ayudar?
Muchas gracias
Saludos
I was getting “unable to load dynamic library php_mssql.dll” because “msvcr71.dll” was missing from windows/system32
Hi Abel,
I just have to say that your work on translating the errors to simple step-by-step solutions is outstanding! I don’t often see support pages as well put together as the one you’ve done, and I read a LOT of support pages at work. I am going to bookmark your site. Please give yourself a round of applause for me
Will
Thank you for this very informative site.
Just this summary on the topic PHP dll’s helped me a lot
Greetings
My problem is finally solved! Thank you very much!
You are genius!!
Thank you.Finally i have solved problem.
Thank you! it helped a lot on a deployment I had to do. It was very confusing the fact of seeing the “unable to load dynamic library php_mssql.dll” error, having the file placed on the right dir. I didn’t know that what it really means is that the file “ntwdblib.dll” is what is missing.
Thanks again!
I have an odd problem. Before, I couldn’t even get my code to “run as php script” (when right mouse button clicking and then selecting “run as php script”, NOTHING happened. And I didn’t even get an error). BUT running as php web page DOES work.
NOW, (suddenly, I don’t know what happened), I can manage to run code as php script, but, the “debug output” is weird: the HTML tags texts appear as they are: , etc…
AND the “console” gives me there errors (which I didn’t understand how to resolve):
PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Users\Roy Peled\Desktop\eclipse\plugins\org.zend.php.debug.debugger.win32.x86_5.2.15.v20081217\resources\php5\ext\php_msql.dll’ – The specified module could not be found.
in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Users\Roy Peled\Desktop\eclipse\plugins\org.zend.php.debug.debugger.win32.x86_5.2.15.v20081217\resources\php5\ext\php_mssql.dll’ – The specified module could not be found.
in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Users\Roy Peled\Desktop\eclipse\plugins\org.zend.php.debug.debugger.win32.x86_5.2.15.v20081217\resources\php5\ext\php_pdo_mssql.dll’ – The specified module could not be found.
in Unknown on line 0
You made my day
After two weekends of headache when trying to make Apache 2 / PHP 5.2.13 talk to my MSSQL server, copying ntwdblib.dll to Apache’s bin directory finally fixed the error!
Thanks a lot, your work is greatly appreciated!!
Regards, Sascha
Glad it helped you, Sascha, I share your feelings about how a nuisance this is if you’re left with clueless errors.
It`s vary good post! I find it this post my solution. Then, I change my php.ini! Thank you!
P.S. Sorry for my terrible English, because I`m from Russia.
YOU ARE MY NEW HERO!
Was losing my mind trying to get the MS SQL driver working with PHP. Gradually starting to realize why everyone says to use the zip version and avoid the installer version.
Glad to be someone’s hero at last!
Indeed, the installer version is terribly thin and incomplete compared to the ZIP version. And there really is no reason that I can think of that it has to be this way.
I spent almost two hours trying to figure this out.
Thank you for the thorough explanation.
in case of PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\\PHP52\\ext\\php_pgsql.dll’ – The operating system cannot run %1.\r\n in Unknown on line 0
.. just go to php conf file and comment the lines
;[PHP_PGSQL]
;extension=php_pgsql.dll(i.e by adding semi colon.)
restart apache.
everythin works fine now
Agreed, but only do so if you do not need the PostGre SQL driver. Otherwise, see my instructions above to fix it to get it working.
Thank you very much.
I am Chinese, and living in mainland(PRC),your tip really help to kill this problem.
I found a lot of solution on internet,but they did not solve the problem well.You are the best.
Thank you
Glad it helped you!
Thank you very much! You are a genious!!
Thank you so much for the information supplied here.
It really bugs me when I get error messages that are not really error messages. When I copied the three dll’s you recommended onto my PHP directory, the ‘error’ messages went away.
The zip install instructions you refer to are for Apache. Do you have similar instructions for Windows?
Thanks again.
Glad it helped you!
About windows: all suggestions above have only been tested on Windows (with Apache 2.2.x for Windows). If you have trouble with the instructions, or if you use a different internet server, I’d be happy to help you along where I can.