5월 112014
 

윈도우에서 아래와 같은 에러가 발생하는 경우 루비 실행파일이 mysql connector 라이브러리인 “libmysql.dll”을 찾지 못해서 발생할 가능성이 높다.

126: The specified module could not be found.   - C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15/lib/mysql2/mysql2.so

mysql가 설치된 폴더의 lib폴더에서 “libmysql.dll”을 windows의 system 폴더(플랫폼x86/x64 주의)에 복사하거나 루비가 설치된 폴더의 bin 폴더(예: c:\ruby193\bin)에 복사를 하도록 하자. 그러면 문제가 해결된다. 자세한 내용은 [1]을 참조하자.

 

참고 자료

[1] http://stackoverflow.com/questions/4241068/rubymine-3-0-setup-on-windows-7

5월 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

 

5월 102014
 

필자의 경우에 회사에서는 MacBook을 이용하고 집에서는 Windows기반의 데스크톱을 이용하고 있다. 회사에는 듀얼모니터가 있기 때문에 작업하는데 딱히 불편함을 느끼지 못 하였다. 하지만 집에는 여분의 모니터가 없고, 이미 데스크톱에 20인치의 듀얼모니터를 이용하고 있기 때문에 데스크톱쪽이 더 효율이 잘 나온다. 물론 집에까지 회사일을 들고와서 하는 것에 대해서는 크게 신경쓰지 말도록 하자. 어쨋든 어차피 회사에서 주로 하는 ruby는 스크립트 언어이고 멀티 플렛폼을 지원하니 집의 윈도우 데스크톱에 ruby를 직접 설치해 보기로 하였다. 필자는 단순히 ruby설치해서 실행시키면 될 것으로 기대했지만, 안타깝게도 설치/설정해야 할 것이 좀 있었다. 아래를 참고해 보도록 하자.

 

1. Ruby 설치

http://rubyinstaller.org/downloads/ 에서 기존 프로젝트에서 사용하던 버젼의 ruby 인스톨 패키지를 설치한다.

 

2. Development Kit(이하 devkit)  설치

몇몇 루비 gem은 네이티브 컴파일을 하기도 하는데 이 경우에 development kit이 필요하다. 해당하는 루비버젼과, 사용자 시스템에 맞는 것을 찾아서 설치 한다.

* 예를들어 json gem의 경우 아래와 같은 에러가 발생하면 devkit를 설치하고 환경변수까지 잡아주어야 한다[1].

ERROR:Error installing json:The'json' native gem requires installed build tools.

* devkit 설치 방법

1) devkit 설치경로: c:\ruby193\devkit

2) ruby 1.9.3 설치경로: c:\ruby193

3) 아래 3개의 명령 실행

c:\ruby193\devkit> ..\bin\ruby dk.rb init

c:\ruby193\devkit> ..\bin\ruby dk.rb review

c:\ruby193\devkit> ..\bin\ruby dk.rb install

* gem 설치시 아래와 같은 에러가 난다면..[2] [3]  (이러한 에러의 발생 이유에 대한 자세한 설명은 [3]를 참조)

1) 여기에서 rebase.exe를 다운로드 받음

2) devkit밑의 bin폴더에 복사 (예:  c:\ruby193\devkit\bin)

3) 아래의 명령을 실행

c:\> cd ruby183\devkit\bin

c:\ruby193\devkit\bin> rebase -b 0x30000000 msys-1.0.dll

 3. Let’s programming!

‘bundle install’ 하고 작업 시작하자! 혹시 mysql에서 또 에러메시지를 본다면 여기, 여기2를 참조하자!!

 

4. 참고 자료


[1] stackoverflow(The ‘json’ native gem requires installed build tools),  http://stackoverflow.com/questions/8100891/the-json-native-gem-requires-installed-build-tools

[2] stackoverflow(Error installing gem: Couldn’t reserve space for cygwin’s heap, Win32 error 487), http://stackoverflow.com/questions/19259272/error-installing-gem-couldnt-reserve-space-for-cygwins-heap-win32-error-487

[3] 아자님의 블로그([MSYS] *** Couldn’t reserve space for cygwin’s heap (0xXXXXXXXX <0xXXXXXXX>) in child, Win32 error 0),  http://azza.tistory.com/152