简体   繁体   English

安装mysql的Rails - 安装mysql2时出错:错误:无法构建gem原生扩展

[英]Rails installing mysql - Error installing mysql2: ERROR: Failed to build gem native extension

I have a Rails 3.2.13 app that I would like deployed, but the hosting service would require MySQL, as opposed to sqlite which I have been using. 我有一个Rails 3.2.13应用程序,我想部署,但托管服务将需要MySQL,而不是我一直在使用的sqlite。

In the process of converting from sqlite to MySQL , I had to install the ruby gem mysql2 , which is giving me the following error upon installing: 在从sqlite转换为MySQL的过程中,我不得不安装ruby gem mysql2 ,它在安装时给出了以下错误:

Error installing mysql2: ERROR: Failed to build gem native extension. 安装mysql2时出错:错误:无法构建gem原生扩展。

I've tried both bundle install , as well as gem install mysql2 , but the same error message appeared. 我已经尝试了bundle install ,以及gem install mysql2 ,但出现了相同的错误消息。

I am aware that the solution that has worked for many is sudo apt-get install libmysql-ruby libmysqlclient-dev , but I'm using Git Bash on Windows , so I found a Windows equivalent (@francois's answer on this question ). 我知道对许多人有效的解决方案是sudo apt-get install libmysql-ruby libmysqlclient-dev ,但是我在Windows上使用Git Bash,所以我发现了Windows等价物(@ francois对这个问题的回答)。 I installed MySQL Server 5.6 with the installer, and ran the following command: 我使用安装程序安装了MySQL Server 5.6 ,并运行以下命令:

gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.6\include"' 

From what I have read, this is supposed to successfully install the 'mysql2' ruby gem. 根据我的阅读,这应该成功安装'mysql2'ruby gem。 But strangely enough, I still had the following error: 但奇怪的是,我仍然有以下错误:

  Temporarily enhancing PATH to include DevKit... Building native extensions with: '--with-mysql-lib="c:\\Program 

Files\\MySQL\\MySQL Server 5.6\\lib" --with-mysql-include="c:\\Program Files\\MySQL\\MySQL Server 5.6\\i nclude"' This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. Files \\ MySQL \\ MySQL Server 5.6 \\ lib“--with-mysql -include =”c:\\ Program Files \\ MySQL \\ MySQL Server 5.6 \\ i nclude“'这可能需要一段时间...错误:安装mysql2时出错:ERROR :无法构建gem原生扩展。

  c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-lib="c:\\Pro gram Files\\MySQL\\MySQL Server 5.6\\lib" --with-mysql-include="c:\\Program Files\\My SQL\\MySQL Server 5.6\\include" 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 main() in -llibmysql... yes checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes creating Makefile 检查rb_intern3()...是检查-llibmysql中的main()...是检查mysql.h ...是检查errmsg.h ...是检查mysqld_error.h ...是创建Makefile

  make generating mysql2-i386-mingw32.def compiling client.c client.c: In function 'rb_raise_mysql2_error': client.c:139:3: 

warning: ISO C90 forbids mixed declarations and code client.c: In function 'finish_and_mark_inactive': client.c:508:3: warning: ISO C90 forbids mixed declarations and code client.c: In function 'rb_mysql_client_abandon_results': client.c:535:3: warning: ISO C90 forbids mixed declarations and code client.c: In function 'rb_mysql_client_next_result': client.c:938:5: 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:407:35: warning: comparison between signed and unsigned integer express ions 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.13\\ext\\mysql2/cl ient.c:158: 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.13\\ext\\mysql2/cl ient.c:150: undefined reference to mysql_init@4' client.o: In func 警告:ISO C90禁止混合声明和代码client.c:在函数'finish_and_mark_inactive'中:client.c:508:3:警告:ISO C90禁止混合声明和代码client.c:在函数'rb_mysql_client_abandon_results'中:client.c: 535:3:警告:ISO C90禁止混合声明和代码client.c:在函数'rb_mysql_client_next_result'中:client.c:938:5:警告:ISO C90禁止混合声明和编译mysql2_ext.c编译result.c结果的代码。 c:在函数'rb_mysql_result_fetch_fields'中:result.c:407:35:警告:有符号和无符号整数表达式离子之间的比较链接共享对象mysql2 / mysql2.so client.o:在函数nogvl_connect': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:158: undefined reference to mysql_real_connect @ 32'client.o:在函数nogvl_init': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:150: undefined reference to mysql_init @ 4'client.o:在func中 tion set_ssl_options': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1078: 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.13\\ext\\mysql2/cl ient.c:723: undefined reference to mysql_options@12' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:727: 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.13\\ext\\mysql2/cl ient.c:267: 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.13\\ext\\mysql2/cl ient.c:257: 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.13\\ext\\mysql2/cl ient.c:370: undefined reference to mysql_store_result@4' client.o: In function set_ssl_options': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1078: undefined reference to mysql_ssl_set @ 24'客户端的set_ssl_options': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1078: undefined reference to .o:函数mysql_client_options': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:723: undefined reference to mysql_options的mysql_client_options': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:723: undefined reference to @ 12'c:\\ RailsInstaller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:727:对mysql_error@4' client.o: In function未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:267:对mysql_info@4' client.o: In function未定义引用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.13 \\ ext \\ mysql2 / client.:257:undefined引用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.13 \\ ext \\ mysql2 / client.c :370:对mysql_store_result@4' client.o: In function未定义引用 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.13\\ext\\mysql2/cl ient.c:923: 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.13\\ext\\mysql2/cl ient.c:863: 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.13\\ext\\mysql2/cl ient.c:894: 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.13\\ext\\mysql2/cl ient.c:856: 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.13\\ext\\mysql2/cl ient.c:825: 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. 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.13 \\ ext \\ mysql2 / client.c:923 :未定义引用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.13 \\ ext \\ mysql2 / client .c:863:未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:894:对mysql_ping的未定义引用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。 13 \\ ext \\ mysql2 / cl ient.c:856:未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:825:对mysql_insert_id@4' client.o: In function未定义引用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.13\\ext\\mysql2/cl ient.c:357: 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.13\\ext\\mysql2/cl ient.c:788: undefined reference to mysql_get_server_version@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:789: 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.13\\ext\\mysql2/cl ient.c:756: undefined reference to mysql_get_client_version@0' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:757: 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.13\\ext\\mysql2/cl ient.c:662: undefined reference to mysql_real_escape_string@16' client.o: In function finish_and_mark_i 1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:357:未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:788:未定义引用mysql_get_server_version@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:789: undefined reference to mysql_get_server_info @ 4'client.o:在函数rb_mysql_client_info': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:756: undefined reference to mysql_get_client_version @ 0'c:\\ RailsInstaller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:757:未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:662:对mysql_real_escape_string@16' client.o: In function未定义引用mysql_real_escape_string@16' client.o: In function finish_and_mark_i中 nactive': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:515: 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.13\\ext\\mysql2/cl ient.c:334: 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.13\\ext\\mysql2/cl ient.c:190: 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.13\\ext\\mysql2/cl ient.c:238: 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.13\\ext\\mysql2/cl ient.c:125: undefined reference to mysql_error@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:126: undefined reference to mysql_sqlstate@4' c:\\RailsIn nactive':c:\\ RailsInstaller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:515:对mysql_free_result@4' client.o: In function未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:334:对mysql_send_query@12' client.o: In function未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:190:undefined引用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.13 \\ ext \\ mysql2 / client.c :238:未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:125:未定义引用mysql_error@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:126: undefined reference to mysql_sqlstate @ 4'c:\\ RailsIn的mysql_error@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:126: undefined reference to staller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:140: 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.13\\ext\\mysql2/cl ient.c:297: undefined reference to mysql_errno@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.13\\ext\\mysql2/cl ient.c:966: 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.13\\ext\\mysql2/cl ient.c:939: 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.13\\ext\\mysql2/cl ient.c:839: 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.13\\ext\\mysql2/cl ient.c:419: u staller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:140:未定义引用mysql_errno@4' client.o: In function rb_connect' :c:\\ RailsInstaller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:297:未定义引用mysql_errno@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.13 \\ ext \\ mysql2 / client.:996:未定义引用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.13 \\ ext \\ mysql2 / client.c:939: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.13 \\ ext \\ mysql2 / client.c:839 :未定义的对mysql_affected_rows@4' client.o: In function引用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.13 \\ ext \\ mysql2 / client .c:419:你 ndefined 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.13\\ext\\mysql2/cl ient.c:539: undefined reference to mysql_next_result@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:538: undefined reference to mysql_more_results@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:547: 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.13\\ext\\mysql2/cl ient.c:368: 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.13\\ext\\mysql2/cl ient.c:190: 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.13\\ext\\mysql2/cl ient.c:1067: undefined referen ndefined引用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.13 \\ ext \\ mysql2 / client。 c:539:未定义引用mysql_next_result@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:538: undefined reference to mysql_more_results @ 4'c:\\ RailsInstaller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / cl ient.c:547:未定义引用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.13 \\ ext \\ mysql2 / client.c:368:undefined reference到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.13 \\ ext \\ mysql2 / cl ient.c: 190:未定义引用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.13 \\ ext \\ mysql2 / cl ient.c:1067:undefined referen ce to mysql_options@12' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1069: undefined reference to mysql_error@4' client.o: In function init_mysql2_client': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1105: undefined reference to mysql_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.13\\ext\\mysql2/re sult.c:576: 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.13\\ext\\mysql2/re sult.c:126: undefined reference to mysql_fetch_field_direct@8' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:114: 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.13\\ext\\mysql2/re sult.c:403: u ce to mysql_options@12' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1069: undefined reference to mysql_error @ 4 'client.o:在函数init_mysql2_client': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/cl ient.c:1105: undefined reference to mysql_get_client_info @ 0'come.o:在函数rb_mysql_result_count': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:576: undefined reference to mysql_num_rows的rb_mysql_result_count': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:576: undefined reference to @ 4'rend.o:在函数rb_mysql_result_fetch_field': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:126: undefined reference to mysql_fetch_field_direct @ 8'c:\\ RailsInstaller \\ Ruby1.9.3 \\ lib \\ ruby​​ \\ gems \\ 1.9.1 \\ gems \\ mysql2-0.3.13 \\ ext \\ mysql2 / re sult.c:114 :未定义的对mysql_num_fields@4' result.o: In function引用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.13 \\ ext \\ mysql2 / re sult .c:403:你 ndefined 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.13\\ext\\mysql2/re sult.c:105: 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.13\\ext\\mysql2/re sult.c:75: 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.13\\ext\\mysql2/re sult.c:213: undefined reference to mysql_fetch_lengths@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:215: 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.13\\ext\\mysql2/re sult.c:503: 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.13\\ext\\mysql2/re sult.c:75: undefined reference to ndefined对mysql_num_fields@4' result.o: In function引用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.13 \\ ext \\ mysql2 / re sult。 c:105:未定义引用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.13 \\ ext \\ mysql2 / re sult.c:75:对mysql_free_result@4' result.o: In function未定义引用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.13 \\ ext \\ mysql2 / re sult.c:213:未定义引用mysql_fetch_lengths@4' c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:215: undefined reference to mysql_num_fields @ 4'rend.o:函数rb_mysql_result_each': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:503: undefined reference to mysql_fetch_fields的rb_mysql_result_each': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:503: undefined reference to @ 4'rend.o:在函数rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: undefined reference to rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: 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.13\\ext\\mysql2/re sult.c:531: 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.13\\ext\\mysql2/re sult.c:75: 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.13\\ext\\mysql2/re sult.c:490: 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.13\\ext\\mysql2/re sult.c:75: undefined reference to mysql_free_result@4' collect2: ld returned 1 exit status make: *** [mysql2.so] Error 1 rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: undefined reference to mysql_free_result的rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: undefined reference to @ 4'rend.o:在函数rb_mysql_result_each': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:531: undefined reference to mysql_fetch_fields @ 4'sult.o:在函数rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: undefined reference to mysql_free_result的rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: undefined reference to @ 4'sult.o:在函数rb_mysql_result_each': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:490: undefined reference to mysql_num_rows @ 4'rend.o:在函数rb_mysql_result_free_result': c:\\RailsInstaller\\Ruby1.9.3\\lib\\ruby\\gems\\1.9.1\\gems\\mysql2-0.3.13\\ext\\mysql2/re sult.c:75: undefined reference to mysql_free_result @ 4' collect2:ld返回1退出状态make:*** [mysql2.so]错误1

  Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9 .1/gems/mysql2-0.3.13 

for inspection. 检查。 Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0. 结果记录到c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0。 3.13/ext/mysql2/gem_make.out 3.13 / EXT / mysql2 / gem_make.out

 Can anyone please help? I am having much trouble comprehending what's wrong with the installation. 

I had this same error on Win64 environment. 我在Win64环境中遇到了同样的错误。

I tested a lot of solutions but the only that worked for me was: 我测试了很多解决方案,但唯一对我有用的是:

  • gem install mysql2 -v '0.3.11' gem install mysql2 -v'0.3.11'

I've been so annoyed by the same problem, and finally succeeded in installing mysql2 . 我一直对同样的问题感到恼火,终于成功安装了mysql2 Kudos to odiszapc@github . 感谢odiszapc @ github It appears any other solution I've found via Google than below doesn't work to me. 看来我通过谷歌发现的任何其他解决方案都不适用于我。

Copied and pasted from here . 复制并粘贴在这里 So no credit to me. 所以没有信任我。

gem uninstall mysql2

Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-    connector-c-noinstall-6.0.2-win32.zip

Extract it to C:\connector-6.0.2

gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-dir="C:\connector-6.0.2"'

Additional info on mine. 关于我的其他信息。

  • ruby 1.9.3p392 (2013-02-22) [i386-mingw32] ruby 1.9.3p392(2013-02-22)[i386-mingw32]
  • Rails 3.2.13 Rails 3.2.13
  • MySQL Server 5.6 MySQL Server 5.6
  • mysql2-0.3.13 mysql2-0.3.13

PS Even if you successfully installed mysql2 , you may still need some work (eg mysql2.so (LoadError)), and it has something do with libmysql in my case, and seems like yet another major glitch about mysql2. PS即使您成功安装了mysql2 ,您可能仍需要一些工作(例如mysql2.so(LoadError)),并且在我的情况下它与libmysql有关,似乎是另一个关于mysql2的重大故障。

I am installing on Windows 7 64 bit. 我在Windows 7 64位上安装。 What worked for me was: 对我有用的是:

Download the C 32 bit connector archive from: http://dev.mysql.com/downloads/connector/c/ 从以下网址下载C 32位连接器存档: http//dev.mysql.com/downloads/connector/c/

I extracted it to C:\\Temp. 我把它提取到C:\\ Temp。 If you use a different directory, adjust the next command. 如果使用其他目录,请调整下一个命令。

gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\Temp\mysql-connector-c-6.1.3-win32"'

pain... lot of pain. 痛苦......很痛苦。 Finally working doing: 最后工作做:

(Platform: Windows64bits, Ruby32bits, DevKit32bits...) (平台:Windows64bits,Ruby32bits,DevKit32bits ......)

  1. Download mysql connector for C from http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick下载C语言的mysql连接器
  2. Unzip connector in a directory without spaces in names! 在名称中没有空格的目录中解压缩连接器!
  3. Copy lib/libmysql.dll file into ruby/bin one 将lib / libmysql.dll文件复制到ruby / bin中
  4. gem install mysql2 -- --with-mysql-dir=D:\\RoR\\mysql-connector-c (so give the dir of connector and not the dir of server) gem install mysql2 - --with-mysql-dir = D:\\ RoR \\ mysql-connector-c(所以给连接器的目录而不是服务器的目录)

And I got mysql2 v0.3.17 up and running... 我启动并运行了mysql2 v0.3.17 ...

  1. Download Mysql connector from 从下载Mysql连接器
    http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick . http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
  2. Extract it. 提取它。 copy lib\\libmysql.dll file and paste it in Ruby's bin directory ex: C:\\RailsInstaller\\Ruby1.9.3\\bin 复制lib \\ libmysql.dll文件并将其粘贴到Ruby的bin目录ex: C:\\ RailsInstaller \\ Ruby1.9.3 \\ bin
  3. Now again install Mysql2 gem 现在再次安装Mysql2 gem
    gem install mysql2 -- '--with-mysql-lib="c:\\Program Files\\MySQL\\MySQL Server 5.0\\lib\\opt" --with-mysql-include="c:\\Program Files\\MySQL\\MySQL Server 5.0\\include"' gem install mysql2 - ' - with-mysql-lib =“c:\\ Program Files \\ MySQL \\ MySQL Server 5.0 \\ lib \\ opt”--with-mysql-include =“c:\\ Program Files \\ MySQL \\ MySQL Server 5.0 \\包括“”
    note: change mysql installation path as per yours 注意:根据您的需要更改mysql安装路径
  4. Try to bundle now 尝试现在捆绑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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