1

we tried suggestions from this SO post about correcting installation errors with the mysql2 gem, but our problems persisted. we also looked at other SO posts like this one, but none helped.

we're on rails 3.2.12 on windows 7.

libmysql.dll is installed in C:\RailsInstaller\Ruby1.9.3\bin, though this was installed in March 2013.

error:

Using mongo_mapper (0.12.0)
Installing mysql2 (0.3.15)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/RailsInstaller/Ruby1.9.3/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib


Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15/ext/mysql2/gem_m
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.
Community
  • 1
  • 1
Crashalot
  • 33,605
  • 61
  • 269
  • 439
  • You have tried this command with your own values for lib and include directories location and it failed, right? gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"' – andHapp Feb 12 '14 at 06:52
  • not yet, we'll try it. – Crashalot Feb 12 '14 at 06:57
  • we're missing the "include" folder, only have "bin," "data," "lib," and "share" folders under "MySQL Server 5.5." – Crashalot Feb 12 '14 at 07:00
  • 1
    @andHapp any suggestions on what to do? – Crashalot Feb 12 '14 at 07:06

1 Answers1

0

Wrote an update on how to do this (after we've had to do it a lot):

  • Download MYSQL C-Connector Library (32-bit only)
  • Unzip to "no-spaces" path (E.G C:/mysql-connector)
  • Install the gem using relative paths:
gem install mysql2 —platform=ruby — ‘—with-mysql-dir=”C:\mysql-connector-path”’
  • Add the DLL to your Ruby/bin folder (you've done already)

Reason

The reason this fails is because Win 7 does not have MYSQL libraries installed, meaning Ruby cannot reference the files it needs to install the gem

You need to install the correct files (which can be removed later on). It seems you've installed the wrong ones, which will probably be the reason why the gem fails to install

Hope this helps!

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • thanks for the answer, but this failed (we installed the ZIP file, not the executable). Error: https://gist.github.com/anonymous/9220767. Any suggestions? – Crashalot Feb 26 '14 at 00:14