DLL handling in Windows x64: The Big Gotcha

I had a nasty time trying to get the PHP module to run under Apache 2.2 in Windows 7 x64.  Specifically, I kept getting a “php_mysql.dll could not be loaded” error. After some sleuthing, decided to use Dependency Walker to help figure out what was wrong.  It turns out that I had installed the 64-bit version of MySQL and so it was trying to load the 64-bit version of libmysql.dll.  So instead, I must use the 32-bit version of libmysql.dll.  Traditionally, the way to do this is to manually copy libmysql.dll over to the \Windows\System32 directory, and after reading the entry below, I realized I was going to save myself countless hours because I saw this before I was going to attempt the copy:

http://blogs.msdn.com/ashishme/archive/2009/04/01/32-bit-vs-64-bit.aspx

In a nutshell, what this means is that on 64-bit Windoze, you should copy your 32-bit dlls into \Windows\SysWOW64 rather than \Windows\System32 otherwise, your 32-bit programs will never find them.  Why?  This is because all 32-bit programs running on Windows x64 are handled by the WOW64 emulator which transparently maps all access to \Windows\System32 to \Windows\SysWOW64\Windows\System32 on Windows x64 is, ironically, reserved for 64-bit dlls.  MS claims this had to be done for compatibility reasons.


Leave a Reply

Your email address will not be published. Required fields are marked *