0

我在安装包安装失败后尝试安装 mysql2 gem。当我跑步时

$ sudo gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

我收到以下错误:

构建原生扩展。这可能需要一段时间... 错误:安装 mysql2 时出错:错误:无法构建 gem 原生扩展。

    /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config

检查 rb_thread_blocking_region()... 是 检查 rb_wait_for_single_fd()... 是 检查 mysql.h... 是 检查 errmsg.h... 是 检查 mysqld_error.h... 是 创建 Makefile

编译client.c 在client.c:1中包含的文件中:在./mysql2_ext.h:8中包含的文件中:在/Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include中包含的文件中/ruby-1.9.1/ruby.h:32: /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:105:37: 错误: 'ruby_check_sizeof_long' 声明为具有负大小 typedef char ruby​​_check_sizeof_long[SIZEOF_LONG == sizeof(long) 的数组?1:-1];^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 在来自client.c的文件中:1:在来自的文件中./mysql2_ext.h:8:在 /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32 包含的文件中:在 /Users 包含的文件中/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:24:/Users/jcollyer/.rvm/rubies/ruby-1.9。

定义 SIZEOF_LONG 8

                ^ In file included from client.c:1: In file included from ./mysql2_ext.h:8: In file included from

/Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32:/Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/ include/ruby-1.9.1/ruby/ruby.h:109:38: 错误: 'ruby_check_sizeof_voidp' 声明为具有负大小 typedef char ruby​​_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) 的数组?1:-1];^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 在来自client.c的文件中:1:在文件中包含在 ./mysql2_ext.h:8 中:包含在 /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32 中的文件中:包含在文件中/Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:24:/Users/jcollyer/.rvm/rubies/ruby-1.9.3- p327/include/ruby-1.9.1/x86_64-darwin11.4.2/ruby/config.h:28:22:注意:实例化自:

定义 SIZEOF_VOIDP 8

                 ^ In file included from client.c:1: In file included from ./mysql2_ext.h:8: In file included from

/Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32:在 /Users/jcollyer/.rvm/rubies/ruby-1.9 包含的文件中。 3-p327/include/ruby-1.9.1/ruby/ruby.h:1382:在 /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ 包含的文件中ruby/intern.h:34: /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/st.h:67:45: 错误: 'st_check_for_sizeof_st_index_t' 声明作为具有负大小 typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) 的数组?1:-1];^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 在文件中包含在 client.c:1 中:包含在 ./mysql2_ext.h:8 中的文件中:包含在 /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ 中的文件中ruby.h:32:

定义 SIZEOF_VOIDP 8

                 ^ 3 errors generated. make: *** [client.o] Error 1

Gem 文件将继续安装在 /Users/jcollyer/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11 以供检查。结果记录到 /Users/jcollyer/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

$ 哪个红宝石

/Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/bin/ruby

$哪里mysql

/usr/local/bin/mysql

我错过了什么?

4

2 回答 2

1

如果您打算为您的应用程序使用 mysql2 gem,那么您需要libmysqlclient-dev在执行此操作之前安装该软件包。更多详情:
http ://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

于 2013-01-08T07:34:32.190 回答
0

试试这个希望它会有所帮助

cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

如果这不起作用,则安装 libmysqlclient15-dev

每当您无法构建“本机扩展”时,就意味着缺少一些 lib 或 lib-dev。通常你需要做一个

sudo apt-get install 
lib-???-dev

sudo apt-get install build_essential

'sudo apt-get install libmysqlclient15-dev'
于 2013-01-08T06:27:53.277 回答