I'm installing on a Win7 x64 machine and am having difficulty getting mysql2 to install. I have proceeded through the proper steps here. I have installed Ruby on Rails with Railsinstaller, copied the .dll file and .lib file into the ruby home folder, etc. Here are the results from my gem install command string:
$ gem install mysql2 -v 0.3.14 --platform=ruby -- '--with-mysql-dir="c:\MySQL-Connector-C-6.1"'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-dir="c:\MySQL-Connector-C-6.1"
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
Using --with-mysql-dir=c:\MySQL-Connector-C-6.1
checking for main() in -llibmysql... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
Setting rpath to /lib
creating Makefile
make
generating mysql2-i386-mingw32.def
compiling client.c
client.c: In function 'finish_and_mark_inactive':
client.c:509:3: warning: ISO C90 forbids mixed declarations and code
compiling mysql2_ext.c
compiling result.c
result.c: In function 'rb_mysql_result_fetch_fields':
result.c:422:35: warning: comparison between signed and unsigned integer expressions
linking shared-object mysql2/mysql2.so
client.o: In function nogvl_connect':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:159: undefined reference tomys
ql_real_connect@32'
client.o: In function nogvl_init':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:151: undefined reference tomys
ql_init@4'
client.o: In function set_ssl_options':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:1098: undefined reference tomy
sql_ssl_set@24'
client.o: In function mysql_client_options':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:740: undefined reference tomys
ql_options@12'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:744: undefined reference to mys
ql_error@4'
client.o: In functionrb_mysql_info':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:268: undefined reference to mys
ql_info@4'
client.o: In functionrb_mysql_client_warning_count':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:258: undefined reference to mys
ql_warning_count@4'
client.o: In functionnogvl_do_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:371: undefined reference to mys
ql_store_result@4'
client.o: In functionrb_mysql_client_more_results':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:943: undefined reference to mys
ql_more_results@4'
client.o: In functionnogvl_select_db':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:883: undefined reference to mys
ql_select_db@8'
client.o: In functionnogvl_ping':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:914: undefined reference to mys
ql_ping@4'
client.o: In functionrb_mysql_client_thread_id':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:876: undefined reference to mys
ql_thread_id@4'
client.o: In functionrb_mysql_client_last_id':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:845: undefined reference to mys
ql_insert_id@4'
client.o: In functionnogvl_read_query_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:358: undefined reference to mys
ql_read_query_result@4'
client.o: In functionrb_mysql_client_server_info':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:805: undefined reference to mys
ql_get_server_version@4'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:806: undefined reference tomys
ql_get_server_info@4'
client.o: In function rb_mysql_client_info':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:773: undefined reference tomys
ql_get_client_version@0'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:774: undefined reference to mys
ql_get_client_info@0'
client.o: In functionrb_mysql_client_real_escape':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:663: undefined reference to mys
ql_real_escape_string@16'
client.o: In functionfinish_and_mark_inactive':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:516: undefined reference to mys
ql_free_result@4'
client.o: In functionnogvl_send_query':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:335: undefined reference to mys
ql_send_query@12'
client.o: In functionnogvl_close':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:191: undefined reference to mys
ql_close@4'
client.o: In functionrb_mysql_client_escape':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:239: undefined reference to mys
ql_escape_string@12'
client.o: In functionrb_raise_mysql2_error':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:125: undefined reference to mys
ql_error@4'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:126: undefined reference tomys
ql_sqlstate@4'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:141: undefined reference to mys
ql_errno@4'
client.o: In functionrb_connect':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:298: undefined reference to mys
ql_errno@4'
client.o: In functionrb_mysql_client_store_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:986: undefined reference to mys
ql_errno@4'
client.o: In functionrb_mysql_client_next_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:959: undefined reference to mys
ql_next_result@4'
client.o: In functionrb_mysql_client_affected_rows':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:859: undefined reference to mys
ql_affected_rows@4'
client.o: In functionrb_mysql_client_async_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:420: undefined reference to mys
ql_errno@4'
client.o: In functionrb_mysql_client_abandon_results':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:540: undefined reference to mys
ql_next_result@4'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:539: undefined reference tomys
ql_more_results@4'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:548: undefined reference to mys
ql_free_result@4'
client.o: In functionnogvl_do_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:369: undefined reference to mys
ql_use_result@4'
client.o: In functionnogvl_close':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:191: undefined reference to mys
ql_close@4'
client.o: In functionset_charset_name':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:1087: undefined reference to my
sql_options@12'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:1089: undefined reference tomy
sql_error@4'
client.o: In function init_mysql2_client':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/client.c:1137: undefined reference tomy
sql_get_client_info@0'
result.o: In function rb_mysql_result_count':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:591: undefined reference tomys
ql_num_rows@4'
result.o: In function rb_mysql_result_fetch_field':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:126: undefined reference tomys
ql_fetch_field_direct@8'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:114: undefined reference to mys
ql_num_fields@4'
result.o: In functionrb_mysql_result_fetch_fields':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:418: undefined reference to mys
ql_num_fields@4'
result.o: In functionnogvl_fetch_row':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:105: undefined reference to mys
ql_fetch_row@4'
result.o: In functionrb_mysql_result_free_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:75: undefined reference to mysq
l_free_result@4'
result.o: In functionrb_mysql_result_fetch_row':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:216: undefined reference to mys
ql_fetch_lengths@4'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:218: undefined reference tomys
ql_num_fields@4'
result.o: In function rb_mysql_result_each':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:518: undefined reference tomys
ql_fetch_fields@4'
result.o: In function rb_mysql_result_free_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:75: undefined reference tomysq
l_free_result@4'
result.o: In function rb_mysql_result_each':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:546: undefined reference tomys
ql_fetch_fields@4'
result.o: In function rb_mysql_result_free_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:75: undefined reference tomysq
l_free_result@4'
result.o: In function rb_mysql_result_each':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:505: undefined reference tomys
ql_num_rows@4'
result.o: In function rb_mysql_result_free_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\ext\mysql2/result.c:75: undefined reference tomysq
l_free_result@4'
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1
Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14/ext/mysql2/gem_make.out
It turns out the problem causing these errors was a 32 bit / 64 bit mismatch. To resolve it I simply uninstalled the 64 bit version of MySQL Connector and installed the 32 bit version. After that everything compiled fine. Thanks to Aaron Stone for drawing my attention to the solution here.