The specific version of mysql2 gem you're trying to install (0.2.4) not only lacks binaries for Windows, but have issues on Windows.
Please install mysql2 gem without indicating the version:
gem install mysql2
Which will install latest version (0.2.6 at the time of my posting this) and also provides binaries for Windows which skip the compilation step.
If you still want to force the compilation (because your version of MySQL differs from the one used to generate the binary gem, you will need to install RubyInstaller's DevKit from RubyInstaller website:
http://rubyinstaller.org/downloads
And follow the DevKit installation instructions from our wiki (that is linked from the download page)
You will need to provide the path to both headers and libraries during the gem installation process, and adjust the MySQL installation location from the following instructions:
subst X: "C:Program Files (x86)MySQLMySQL Server 5.1"
gem install mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:libopt
subst X: /D
The above command uses subst
to avoid issues with path with spaces, which you should avoid always.
Hope this helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…