Installing software is always fun. A recent purchase of new computer forced to redo the setup of my test web developement environment (i.e. Apache + PHP + MySQL) under Windows XP. Something I did at least 3 times in the past. PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php-514\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0 It's mysterious because the file clearly is there. Lucky for me that I misspent part of my life doing Windows programming, which includes intricacies of DLL loading, and I know that a DLL might not get loaded even if it exists when it refers to another DLL that is not present in %PATH%. After some googling I found that others had the same problem and the solution proposed was to copy libmysql.dll to c:\windows or c:\windows\system32. Polluting system directories is a gross solution but at the time I would be happy if things just worked. However, copying libmysql.dll to c:\windows didn't solve the problem. In a flash of inspiration I decided to run Dependency Walker on php_mysql.dll to see what else it might depend on. Turns out it also needs php5ts.dll and probably in some cases msjava.dll (that is nowhere to be found and fortunately doesn't seem necessary). I copied php5ts.dll to c:\windows as well and voila, things work. I, however, am left with a bad taste in my mouth. More on that later, now let's recap wisdom gained:
Now about bad taste in my mouth. Apache and PHP are amongst the most popular open-source project and yet the Windows experience of using them is awful. Managing dependencies is a nightmare (3 versions of Apache + a dozen versions of PHP, good luck figuring out what's compatible with what). Open-source world, in general, is not good about maintaining binary compatibility. Apache 2.0 was supposed to be the big rewrite, what was so important to add to Apache 2.2 to justify a 3rd, incompatible binary interface. Forcing people to copy DLL to system folders to make things work is bad and easily fixable. PHP could easily figure out the path of their main DLL and add it to path so that DLLs that it knows live there could be loaded by system. Let's not forget misleading error messages. Could not be found? But it's there! Windows is partly to blame, because that's probably the error that it returns to PHP, but given that it seems to be a common problem, it could be smart enough to stat the file to see whether it's really not there or it's not loading because of some other reason. Given those problems it's only a minor issue that Apache Foundations seems to change their minds about where Apache is being installed about once a year. |