安装mysql的Rails - 安装mysql2时出错:错误:无法构建gem本机扩展 [英] Rails installing mysql - Error installing mysql2: ERROR: Failed to build gem native extension

查看:854
本文介绍了安装mysql的Rails - 安装mysql2时出错:错误:无法构建gem本机扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我想要部署的 Rails 3.2.13 应用程序,但主机服务将需要MySQL,而不是我一直在使用的sqlite。在$ code> sqlite 转换为 MySQL 的过程中,我不得不安装ruby gem mysql2 ,这在安装时给我以下错误:


安装mysql2时出错:错误:无法构建gem本机扩展。


我尝试过捆绑安装,以及 gem install mysql2 ,但出现相同的错误消息。



我知道许多的解决方案是 sudo apt-get install libmysql-ruby libmysqlclient-dev ,但是我使用Git Bash在 Windows ,所以我发现一个Windows的等效项(@ francois的答案在这个问题)。我使用安装程序安装了 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'

从我读过的,这是应该成功安装'mysql2'ruby宝石。但是奇怪的是,我仍然遇到以下错误:


 临时增强PATH以包含DevKit ..建立本机扩展名:'--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'这可能需要一个而...
错误:安装mysql2时出错:
错误:无法构建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检查rb_thread_blocking_region()...是检查rb_wait_for_single_fd()...是检查rb_hash_dup()...是

检查rb_intern3()。 ..是检查main()在-llibmysql ...
是检查mysql.h ...是检查errmsg.h ...是检查
为mysqld_error.h ...是创建Makefile

 使生成mysql2-i386-mingw32.def编译client.c client.c:在函数'rb_raise_mysql2_error'中:客户端.c:139:3:

警告:ISO C90禁止混合声明和代码client.c:In
函数'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 result.c:在函数'rb_mysql_result_fetch_fields'中:
result.c:407:35:warning:签名和无符号
整数表达式离子链接共享对象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:未定义引用
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:未定义引用
mysql_init @ 4'client.o:In
函数 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:未定义引用
mysql_ssl_set @ 24'client.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:未定义引用
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 :未定义引用 mysql_error @ 4'client.o:
函数
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:
函数
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:未定义引用 mysql_warning_count @ 4'client.o:
功能
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:未定义引用 mysql_store_result @ 4'client.o:In
函数
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:未定义引用 mysql_more_results @ 4'client.o:
函数
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:未定义引用 mysql_select_db @ 8'client.o:
函数
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 @ 4'client.o:
函数
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:
函数
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:
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:未定义的引用 mysql_read_query_result @ 4'
client.o:在函数
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:未定义引用 m ysql_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:未定义引用
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:未定义引用
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:
在函数中
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_escap e_string @ 16'
client.o:在函数中
finish_and_mark_inactive':
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:
函数
nogvl_send_query':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.13\\ \\\\ mysql2 / cl
ient.c:334:未定义引用 mysql_send_query @ 12'client.o:
函数
nogvl_close'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.13\ext\mysql2 / cl
.c:190:未定义引用 mysql_close @ 4'client.o:
函数
rb_mysql_client_escape':
c:\RailsInstaller\Ruby1。 9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.13\ext\mys ql2 / cl
ient.c:238:未定义引用 mysql_escape_string @ 12'client.o:
在函数中
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:未定义引用
mysql_sqlstate @ 4'
c:\RailsInstaller\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:
函数
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_errn o @ 4'client.o:
函数
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:未定义引用 mysql_errno @ 4'client.o:
函数
rb_mysql_client_next_result':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.13\\ \\mysql2 / cl
ient.c:939:未定义引用 mysql_next_result @ 4'client.o:
函数
rb_mysql_client_affected_rows'
c:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\mysql2-0.3.13\ext\mysql2 / cl
.c:839:未定义引用 mysql_affected_rows @ 4'client.o:
在函数中
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:未定义引用 mysql_errno @ 4'client.o:
函数
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:未定义引用 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:未定义引用
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:未定义的引用到$ code> mysql_free_result @ 4'client.o:
函数 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:未定义引用 mysql_use_result @ 4'client.o:
函数
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:
函数
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:未定义引用 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 :未定义引用
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:11 05:未定义引用
mysql_get_client_info @ 0'
result.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:未定义引用
mysql_num_rows @ 4'result.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:未定义引用
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:
函数
rb_mysql_result_fetch_fields':
c:\RailsInstaller\Ruby1.9.3\lib\ruby\\ \\gems\1.9.1\gems\mysql2-0.3.13 \\\\ mysql2 / re
sult.c:403:未定义引用 mysql_num_fields @ 4'result.o:
函数
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:
函数
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:
函数
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\gem s\mysql2-0.3.13\ext\mysql2 / re
sult.c:215:未定义的引用
mysql_num_fields @ 4'result.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:未定义的引用
mysql_fetch_fields @ 4'result.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:未定义引用
mysql_free_result @ 4'result.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:未定义引用
mysql_fetch_fields @ 4'result.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:未定义引用
mysql_free_result @ 4'result.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:未定义引用
mysql_num_rows @ 4'result.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:未定义引用
mysql_free_result @ 4'collect2:ld
返回1退出状态使: * [mysql2.so]错误1

 宝石文件将保持安装c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9 .1 / gems / mysql2-0.3.13 

fo r检查。结果记录到
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0。
3.13 / ext / mysql2 / gem_make.out

 任何人都可以帮忙?我很难理解安装有什么问题。 



解决方案

在Win64环境中出现同样的错误。



我测试了很多解决方案,但唯一对我有用的是:




  • gem install mysql2 -v'0.3.11'


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.

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:

Error installing mysql2: ERROR: Failed to build gem native extension.

I've tried both bundle install, as well as gem install mysql2, but the same error message appeared.

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). I installed MySQL Server 5.6 with the installer, and ran the following command:

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. 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.

        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

    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 tomysql_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 tomysql_init@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 tomysql_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 tomysql_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 functionrb_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 functionrb_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 functionnogvl_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 functionrb_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 functionnogvl_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 functionnogvl_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 functionrb_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 functionrb_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 functionnogvl_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 functionrb_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 tomysql_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 tomysql_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 functionrb_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 functionfinish_and_mark_inactive': 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 functionnogvl_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 functionnogvl_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 functionrb_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 functionrb_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 tomysql_sqlstate@4' c:\RailsInstaller\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 functionrb_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 functionrb_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 functionrb_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 functionrb_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 functionrb_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: undefined reference to mysql_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.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 tomysql_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 functionnogvl_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 functionnogvl_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 functionset_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 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:1069: undefined reference tomysql_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 tomysql_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 tomysql_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 tomysql_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 functionrb_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: undefined reference to mysql_num_fields@4' result.o: In functionnogvl_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 functionrb_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 functionrb_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 tomysql_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 tomysql_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 tomysql_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 tomysql_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 tomysql_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 tomysql_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 tomysql_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.13

for inspection. Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0. 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.

I tested a lot of solutions but the only that worked for me was:

  • gem install mysql2 -v '0.3.11'

这篇关于安装mysql的Rails - 安装mysql2时出错:错误:无法构建gem本机扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆