简体   繁体   中英

Ruby on Windows: Cannot install mysql2 gem - Failed to build gem native extension

I tried to follow posts here and there

But I'm nowhere near enough to reach the truth answer to this problem.

Is there something else I'm missing here?

d:\Projects\Ruby\cms>gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-c-6.1.3-winx64"'
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.3-winx64"
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.3-winx64
-----
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:513:3: warning: ISO C90 forbids mixed declarations and code
compiling infile.c
compiling mysql2_ext.c
compiling result.c
result.c: In function 'rb_mysql_result_fetch_fields':
result.c:415: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.15\ext\mysql2/client.c:157: undefined reference to `mysql_real_connect@32'
client.o: In function `nogvl_init':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:146: undefined reference to `mysql_init@4'
client.o: In function `set_ssl_options':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1102: undefined reference to `mysql_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.15\ext\mysql2/client.c:744: undefined reference to `mysql_options@12'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:748: undefined reference to `mysql_error@4'
client.o: In function `rb_mysql_info':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:271: undefined reference to `mysql_info@4'
client.o: In function `rb_mysql_client_warning_count':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:261: undefined reference to `mysql_warning_count@4'
client.o: In function `nogvl_do_result':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:375: undefined reference to `mysql_store_result@4'
client.o: In function `rb_mysql_client_more_results':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:947: undefined reference to `mysql_more_results@4'
client.o: In function `nogvl_select_db':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:887: undefined reference to `mysql_select_db@8'
client.o: In function `nogvl_ping':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:918: undefined reference to `mysql_ping@4'
client.o: In function `rb_mysql_client_thread_id':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:880: undefined reference to `mysql_thread_id@4'
client.o: In function `rb_mysql_client_last_id':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:849: undefined reference to `mysql_insert_id@4'
client.o: In function `nogvl_read_query_result':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:362: undefined reference to `mysql_read_query_result@4'
client.o: In function `rb_mysql_client_server_info':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:809: undefined reference to `mysql_get_server_version@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:810: undefined reference to `mysql_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.15\ext\mysql2/client.c:777: undefined reference to `mysql_get_client_version@0'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:778: undefined reference to `mysql_get_client_info@0'
client.o: In function `rb_mysql_client_real_escape':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:667: undefined reference to `mysql_real_escape_string@16'
client.o: In function `finish_and_mark_inactive':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:520: undefined reference to `mysql_free_result@4'
client.o: In function `nogvl_send_query':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:339: undefined reference to `mysql_send_query@12'
client.o: In function `nogvl_close':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:189: undefined reference to `mysql_close@4'
client.o: In function `rb_mysql_client_escape':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:242: undefined reference to `mysql_escape_string@12'
client.o: In function `rb_raise_mysql2_error':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:125: undefined reference to `mysql_error@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:126: undefined reference to `mysql_sqlstate@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:135: undefined reference to `mysql_errno@4'
client.o: In function `rb_connect':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:301: undefined reference to `mysql_errno@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:309: undefined reference to `mysql_get_server_version@4'
client.o: In function `rb_mysql_client_store_result':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:990: undefined reference to `mysql_errno@4'
client.o: In function `rb_mysql_client_next_result':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:963: undefined reference to `mysql_next_result@4'
client.o: In function `rb_mysql_client_affected_rows':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:863: undefined reference to `mysql_affected_rows@4'
client.o: In function `rb_mysql_client_async_result':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:424: undefined reference to `mysql_errno@4'
client.o: In function `rb_mysql_client_abandon_results':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:544: undefined reference to `mysql_next_result@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:543: undefined reference to `mysql_more_results@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:552: undefined reference to `mysql_free_result@4'
client.o: In function `nogvl_do_result':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:373: undefined reference to `mysql_use_result@4'
client.o: In function `nogvl_close':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:189: undefined reference to `mysql_close@4'
client.o: In function `set_charset_name':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1091: undefined reference to `mysql_options@12'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1093: undefined reference to `mysql_error@4'
client.o: In function `nogvl_close':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:189: undefined reference to `mysql_close@4'
client.o: In function `init_mysql2_client':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1141: undefined reference to `mysql_get_client_info@0'
infile.o: In function `mysql2_set_local_infile':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/infile.c:114: undefined reference to `mysql_set_local_infile_handler'
result.o: In function `rb_mysql_result_count':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:592: undefined reference to `mysql_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.15\ext\mysql2/result.c:123: undefined reference to `mysql_fetch_field_direct@8'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:111: undefined reference to `mysql_num_fields@4'
result.o: In function `rb_mysql_result_fetch_fields':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:411: undefined reference to `mysql_num_fields@4'
result.o: In function `nogvl_fetch_row':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:102: undefined reference to `mysql_fetch_row@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.15\ext\mysql2/result.c:76: undefined reference to `mysql_free_result@4'
result.o: In function `rb_mysql_result_fetch_row':
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:209: undefined reference to `mysql_fetch_lengths@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:211: undefined reference to `mysql_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.15\ext\mysql2/result.c:512: undefined reference to `mysql_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.15\ext\mysql2/result.c:76: undefined reference to `mysql_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.15\ext\mysql2/result.c:530: undefined reference to `mysql_error@4'
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:547: undefined reference to `mysql_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.15\ext\mysql2/result.c:76: undefined reference to `mysql_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.15\ext\mysql2/result.c:499: undefined reference to `mysql_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.15\ext\mysql2/result.c:76: undefined reference to `mysql_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.15 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15/ext/mysql2/gem_make.out

d:\Projects\Ruby\cms>

You need to use the 32-bit version of MYSQL Connector (I think you're using 64-bit)

MYSQL2 is a pain to install on Windows, but it's only because the dependencies & libraries it requires are not installed natively. You're almost there with the MYSQL C-Connector, but you'll have to uninstall & download the 32 bit version

Never mind.

I figured out what went wrong with it.

Because I installed 32bit MySQL Connector ver 6.0 when it should have been ver 6.1 , which is what I originally installed from the beginning.

I got so caught up with the posts and forums here and there that I forgot to double check my originally installation first before blindly accept other people's online solutions.

All good now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM