mysql2 gem无法构建本机扩展 [英] mysql2 gem Can't build native extensions

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

问题描述

实习生的电脑在安装mysql2 gem时遇到了问题。我们只是将他的电脑从OS X 10.6升级到了10.8(Mountain Lion)。我曾尝试通过自制软件和64位DMG安装程序安装MySQL。我也尝试了对开发工具的符号链接(正如这里指出的那样:山狮升级后无法安装一些宝石)。我们安装了Xcode(4.4)并安装了命令行工具。我们在安装命令行工具后尝试重新启动。



这是他从〜/ .bashrc 的PATH声明:

  PATH = / usr / local / bin:$ PATH:$ HOME / .rvm / bin:/ usr / local / mysql / bin#将RVM添加到PATH脚本中

符号链接:

  Diego-Blantons-MacBook-Pro-3:〜lmrunner07 $ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 
密码:

尝试安装gem:

  Diego-Blantons-MacBook-Pro-3:〜lmrunner07 $ gem install mysql2 
构建原生扩展。这可能需要一段时间...
错误:安装mysql2时出错:
错误:无法构建gem本机扩展。

/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
检查rb_thread_blocking_region()...是
检查对于rb_wait_for_single_fd()...是
检查mysql.h ...是
检查errmsg.h ...是
检查mysqld_error.h ...是
创建Makefile
$ b $ make make
编译client.c
从/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-包含的文件中, 1.9.1 / ruby​​.h:32,
来自./mysql2_ext.h:8,
来自client.c:1:
/Users/lmrunner07/.rvm/rubies/ruby- 1.9.3-p194 / include / ruby​​-1.9.1 / ruby​​ / ruby​​.h:105:错误:数组'ruby_check_sizeof_long'的大小为负数
/Users/lmrunner07/.rvm/rubies/ruby-1.9。 3-p194 / include / ruby​​-1.9.1 / ruby​​ / ruby​​.h:109:error:array'ruby_check_sizeof_voidp'的大小为负值
从/Users/lmrunner07/.rvm/rubies/ruby- 1.9.3-p194 / include / ruby​​-1.9.1 / ruby​​ / intern.h:34,
来自/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:1382,来自/Users/lmrunner07/.rvm/rubies/的
ruby-1.9.3-p194 / include / ruby​​-1.9.1 / ruby​​.h:32,来自./mysql2_ext.h:8的
,来自client.c的
:1:
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/st.h:67:错误:数组'st_check_for_sizeof_st_index_t'的大小为负值
客户端。 c:在函数'rb_raise_mysql2_error'中:
client.c:98:warning:ISO C90禁止混合声明和代码
client.c:函数'rb_mysql_client_socket':
client.c:590 :警告:ISO C90禁止混合声明和代码
make:*** [client.o]错误1


Gem文件将保持安装在/ Users / lmrunner07 /中。 rvm / gems / ruby​​-1.9.3 -p194 / gems / mysql2-0.3.11进行检查。
结果记录到/Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

我已经删除了自制软件安装的mysql以及启动代理。还有 rm -rf gem目录(Users / lmrunner07 / .rvm / gems / ruby​​-1.9.3-p194 / gems / mysql2-0.3.11)

解决方案

我解决了这个问题:


  1. 安装自制软件 ruby​​ <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
    (查看他们的网站用于 http://mxcl.github.com/homebrew/

  2. 按照这些说明 http:// robots .bug.com / post / 27985816073 / the-hitchhikers-guide-to-riding-a-mountain-lion

  3. 用自制软件重新安装mysql brew安装mysql 。 (我尝试按照以下说明安装mysql: http://erictarn.com/post/28269453881/how-i-installed-mysql-rvm-ruby-and-rails-on-mountain 但我后来遇到问题,所以我会建议重新安装MySQL )

  4. 重新安装rvm和rails以及我的项目(其中包括mysql2)的宝石



注意:当我试图编译时,我有一个库问题, Library未加载:libmysqlclient.18.dylib ,它通过运行 sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib (请参阅未加载库:尝试运行'rails server'时libmysqlclient.16.dylib错误在OS X 10.6与mysql2宝石,如果你得到相同的问题。)


Our intern's computer is having problems installing the mysql2 gem. We just upgraded his computer from OS X 10.6 to 10.8 (Mountain Lion). I have tried installing mysql through homebrew and through the 64 bit DMG installer. I also tried symlinking to the dev tools (as pointed out here: Not able to install some gems after mountain lion upgrade). We have Xcode (4.4) installed and the command line tools installed. We tried a reboot after installing the command line tools.

This is his PATH declaration from ~/.bashrc:

PATH=/usr/local/bin:$PATH:$HOME/.rvm/bin:/usr/local/mysql/bin # Add RVM to PATH for scripting

Symlink:

Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Password:

Try to install gem:

Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

        /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

make
compiling client.c
In file included from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:105: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:109: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/intern.h:34,
                 from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:1382,
                 from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/st.h:67: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
client.c: In function ‘rb_raise_mysql2_error’:
client.c:98: warning: ISO C90 forbids mixed declarations and code
client.c: In function ‘rb_mysql_client_socket’:
client.c:590: warning: ISO C90 forbids mixed declarations and code
make: *** [client.o] Error 1


Gem files will remain installed in /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

I've removed the homebrew installed mysql as well as the launch agent. Also rm -rf the gem directory (Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11)

解决方案

I solved this by:

  1. Installing homebrew ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go) (check out their website for useage http://mxcl.github.com/homebrew/)
  2. Following these instructions http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
  3. Reinstalling mysql with homebrew brew install mysql. (I tried installing mysql by follow these instructions http://erictarn.com/post/28269453881/how-i-installed-mysql-rvm-ruby-and-rails-on-mountain but i ran into issues later so i would recommend reinstalling mysql with homebrew.)
  4. Reinstalling rvm and rails and the gems for my project (which included mysql2)

Note: When I tried to build I had a library issue, Library not loaded: libmysqlclient.18.dylib, which was fixed by running sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib (refer to Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem if you get the same issue.)

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

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