How to compile DBD::mysql on Windows
Putting this down here both for the public and for myself as a reminder.
I still run ActivePerl v12, both because our production servers are at that version and because i see a lot of windows users at that version and lower. I use CPAN a lot and do tend to find obscure issues that break modules on v12 or cause incompatibilities.
However there's a fairly big stone in the way when going that path, since ActiveState has followed their rolling lockdown policy and with the release of Pumpkin Perl v18 locked the PPM servers for v12 (and below) to the public, leaving them only accessible to paying business customers. So i ended up having to compile it manually and this time managed to navigate the maze and figure out the right incantations.
Get the right mysql archiveIn order to the get the correct mysql development files there is no need to install the whole package. Grab the zip file from the official website that matches your perl (32/64) and unpack it anywhere.
Use MSVCDue to the fact that all windows development libs for mysql have been compiled with msvc and contain, among others, bindings to secur32.lib. In my case it was enough to have these installed:
- Microsoft Visual Studio C++ 2010 Express
- the appropiate Windows SDK
Configure lib paths manuallyFirst we'll let CPAN help us prepare the build dir. Open any shell and run:
cpan> look DBD::mysql
Then it is necessary to set PATH up such that Makefile.PL can find mysqladmin.exe:
Running perl Makefile.PL will try to use mysqladmin and mysql_config to determine the appropiate include and lib paths. It's possible that it'll get the lib path right and you can copy the libs arguments it displayed verbatim. However it you see an opt in the lib path, you'll likely need to snip that off so the path points at the dir with mysqlclient.lib. Then you need to add an argument to add secur32 to the lib list and rerun Makefile.PL like so:
perl Makefile.PL --libs=" -LD:\mysql\lib -lmysqlclient -lzlib -lsecur32 "