我有一个Rails 3.2.13
我想部署的应用程序,但托管服务需要 MySQL,而不是我一直在使用的 sqlite。
在从sqlite
to转换的过程中MySQL
,我必须安装 ruby gem mysql2
,这在安装时给了我以下错误:
安装 mysql2 时出错:错误:无法构建 gem 原生扩展。
和 都试过了bundle install
,gem install mysql2
但是出现了同样的错误信息。
我知道对许多人都有效的解决方案是sudo apt-get install libmysql-ruby libmysqlclient-dev
,但我在Windows上使用 Git Bash ,所以我找到了一个 Windows 等价物(@francois's answer on this question)。我使用安装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 gem。但奇怪的是,我仍然有以下错误:
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"' 这可能需要一段时间... 错误:安装 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" checking for rb_thread_blocking_region()... yes checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes
检查 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:
警告: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:在函数中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:在函数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/client.c 中: 727:未定义对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/client.c:267:未定义对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.c:257: 未定义对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
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/client.c:894:未定义对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/client.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/client.c:825:未定义对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/client.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/client.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' 客户端的引用。 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/client.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/client.c:662: 未定义对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.13\ext\mysql2/client.c:515:未定义的引用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/client.c:334: 未定义对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/client.c:190:未定义对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/client.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:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems 的引用\mysql2-0.3.13\ext\mysql2/client.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/client.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.c:966:未定义对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:未定义对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
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:未定义的引用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/client.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: 未定义对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/client.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/client.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: 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' 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: undefined reference to
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: 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/result.c:114:未定义对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:未定义对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/result.c:75: 未定义引用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/result.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' 结果。 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@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: undefined reference to
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: undefined reference to
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: undefined reference to
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: undefined reference to
mysql_num_rows@4'中结果。 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]错误1Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9 .1/gems/mysql2-0.3.13
供检查。结果记录到 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.