May 102014
 

모든 것은 mysql서버를 설치하지 않고 rails를 하려고 한 것에서 시작되었다. 아래와 같은 문제의 경우, 사용하는 ruby의 플렛폼(x86/x64 여부)와 관련된 문제다. 에러 내용이 link 에러여서 좀 더 유심히 보았다. 그랬더니 얻은 결론! mysql connector는 x64 버젼이고 루비는 x86이였던 것이다. 작동 플렛폼이 다르니 당연히 발생하는 문제였다. 아이구… 어쨋든, 여기에서 x86버젼 커넥터를 받아서 설치하여서 경로를 약간 수정해 다시 실행하였더니 성공적으로 설치되었다.

 

1. 해결 방법

1) mysql connect (x86)버젼을 다운로드 받는다.

2) 아래 명령을 실행한다.

C:\Ruby193\bin>gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib" --with-mysql-include="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include"'

 

2. 에러 메시지

C:/Ruby193/bin/ruby.exe extconf.rb --width-mysql-lib="C:\Program Files\M
ySQL\MySQL Connector C 6.1\lib" --width-mysql-include="C:\Program Files\MySQL\My
SQL Connector C 6.1\include" --with-mysql-dir="C:\Program Files\MySQL\MySQL Conn
ector 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:\Program Files\MySQL\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: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 express
ions
linking shared-object mysql2/mysql2.so
client.o: In function `nogvl_connect':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:157: undef
ined reference to `mysql_real_connect@32'
client.o: In function `nogvl_init':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:146: undef
ined reference to `mysql_init@4'
client.o: In function `set_ssl_options':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1102: unde
fined reference to `mysql_ssl_set@24'
client.o: In function `mysql_client_options':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:744: undef
ined reference to `mysql_options@12'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:748: undef
ined reference to `mysql_error@4'
client.o: In function `rb_mysql_info':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:271: undef
ined reference to `mysql_info@4'
client.o: In function `rb_mysql_client_warning_count':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:261: undef
ined reference to `mysql_warning_count@4'
client.o: In function `nogvl_do_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:375: undef
ined reference to `mysql_store_result@4'
client.o: In function `rb_mysql_client_more_results':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:947: undef
ined reference to `mysql_more_results@4'
client.o: In function `nogvl_select_db':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:887: undef
ined reference to `mysql_select_db@8'
client.o: In function `nogvl_ping':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:918: undef
ined reference to `mysql_ping@4'
client.o: In function `rb_mysql_client_thread_id':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:880: undef
ined reference to `mysql_thread_id@4'
client.o: In function `rb_mysql_client_last_id':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:849: undef
ined reference to `mysql_insert_id@4'
client.o: In function `nogvl_read_query_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:362: undef
ined reference to `mysql_read_query_result@4'
client.o: In function `rb_mysql_client_server_info':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:809: undef
ined reference to `mysql_get_server_version@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:810: undef
ined reference to `mysql_get_server_info@4'
client.o: In function `rb_mysql_client_info':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:777: undef
ined reference to `mysql_get_client_version@0'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:778: undef
ined reference to `mysql_get_client_info@0'
client.o: In function `rb_mysql_client_real_escape':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:667: undef
ined reference to `mysql_real_escape_string@16'
client.o: In function `finish_and_mark_inactive':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:520: undef
ined reference to `mysql_free_result@4'
client.o: In function `nogvl_send_query':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:339: undef
ined reference to `mysql_send_query@12'
client.o: In function `nogvl_close':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:189: undef
ined reference to `mysql_close@4'
client.o: In function `rb_mysql_client_escape':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:242: undef
ined reference to `mysql_escape_string@12'
client.o: In function `rb_raise_mysql2_error':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:125: undef
ined reference to `mysql_error@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:126: undef
ined reference to `mysql_sqlstate@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:135: undef
ined reference to `mysql_errno@4'
client.o: In function `rb_connect':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:301: undef
ined reference to `mysql_errno@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:309: undef
ined reference to `mysql_get_server_version@4'
client.o: In function `rb_mysql_client_store_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:990: undef
ined reference to `mysql_errno@4'
client.o: In function `rb_mysql_client_next_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:963: undef
ined reference to `mysql_next_result@4'
client.o: In function `rb_mysql_client_affected_rows':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:863: undef
ined reference to `mysql_affected_rows@4'
client.o: In function `rb_mysql_client_async_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:424: undef
ined reference to `mysql_errno@4'
client.o: In function `rb_mysql_client_abandon_results':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:544: undef
ined reference to `mysql_next_result@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:543: undef
ined reference to `mysql_more_results@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:552: undef
ined reference to `mysql_free_result@4'
client.o: In function `nogvl_do_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:373: undef
ined reference to `mysql_use_result@4'
client.o: In function `nogvl_close':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:189: undef
ined reference to `mysql_close@4'
client.o: In function `set_charset_name':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1091: unde
fined reference to `mysql_options@12'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1093: unde
fined reference to `mysql_error@4'
client.o: In function `nogvl_close':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:189: undef
ined reference to `mysql_close@4'
client.o: In function `init_mysql2_client':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/client.c:1141: unde
fined reference to `mysql_get_client_info@0'
infile.o: In function `mysql2_set_local_infile':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/infile.c:114: undef
ined reference to `mysql_set_local_infile_handler'
result.o: In function `rb_mysql_result_count':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:592: undef
ined reference to `mysql_num_rows@4'
result.o: In function `rb_mysql_result_fetch_field':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:123: undef
ined reference to `mysql_fetch_field_direct@8'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:111: undef
ined reference to `mysql_num_fields@4'
result.o: In function `rb_mysql_result_fetch_fields':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:411: undef
ined reference to `mysql_num_fields@4'
result.o: In function `nogvl_fetch_row':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:102: undef
ined reference to `mysql_fetch_row@4'
result.o: In function `rb_mysql_result_free_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:76: undefi
ned reference to `mysql_free_result@4'
result.o: In function `rb_mysql_result_fetch_row':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:209: undef
ined reference to `mysql_fetch_lengths@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:211: undef
ined reference to `mysql_num_fields@4'
result.o: In function `rb_mysql_result_each':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:512: undef
ined reference to `mysql_fetch_fields@4'
result.o: In function `rb_mysql_result_free_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:76: undefi
ned reference to `mysql_free_result@4'
result.o: In function `rb_mysql_result_each':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:530: undef
ined reference to `mysql_error@4'
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:547: undef
ined reference to `mysql_fetch_fields@4'
result.o: In function `rb_mysql_result_free_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:76: undefi
ned reference to `mysql_free_result@4'
result.o: In function `rb_mysql_result_each':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:499: undef
ined reference to `mysql_num_rows@4'
result.o: In function `rb_mysql_result_free_result':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\mysql2-0.3.15\ext\mysql2/result.c:76: undefi
ned reference to `mysql_free_result@4'
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.
3.15 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15/ext/mysql2/g
em_make.out

 

Dec 132013
 

윈도우에서 mysql2 ruby gem이 아래와 유사한 이유로 설치가 안되는 경우 해결방법. (rails4, ruby2 에서 확인)

Building native extensions. This could take a while…
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for ruby/thread.h… yes
checking for rb_thread_call_without_gvl() in ruby/thread.h… yes
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:/Ruby200-x64/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}/
–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}/
–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:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out

 

 1. 이 유


1. mysqlclient 또는 mysql connector가 설치되어 있지 않기 때문

2. mysql connector가 설치되어 있다 하더라도 경로 지정이 안되있는 경우

 

2. 해결방법


1) mysql c connector를 설치한다. [http://dev.mysql.com/downloads/connector/c/] (설치되어 있는 경우 생략)

2) 아래와 같은 방법으로 설치한다. 굵은 글씨 부분은 mysql connector가 설치된 환경에 맞게 수정한다.

C:\>gem install mysql2 –platform=ruby — ‘–with-mysql-lib=”C:\Program Files\MySQL\MySQL Connector C 6.1\lib” –with-mysql-include=”C:\Program Files\MySQL\MySQL Connector C 6.1\include”‘

 

Reference

[1] http://stackoverflow.com/questions/5836959/cant-install-mysql2-for-rails-3-on-windows