gpt4 book ai didi

ruby-on-rails - mysql2 gem 无法构建原生扩展

转载 作者:行者123 更新时间:2023-12-04 03:35:27 25 4
gpt4 key购买 nike

我们实习生的计算机在安装 mysql2 gem 时出现问题。我们刚刚将他的电脑从 OS X 10.6 升级到 10.8(Mountain Lion)。我尝试通过自制软件和 64 位 DMG 安装程序安装 mysql。我还尝试了符号链接(symbolic link)到开发工具(如此处所指出的: Not able to install some gems after mountain lion upgrade )。我们安装了 Xcode (4.4) 和命令行工具。我们在安装命令行工具后尝试重新启动。

这是他来自 ~/.bashrc 的 PATH 声明:

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

符号链接(symbolic link):
Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Password:

尝试安装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

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

最佳答案

我通过以下方式解决了这个问题:

  • 安装自制软件 ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)(查看他们的网站了解使用情况Link)
  • 遵循这些说明 http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
  • 用自制软件重新安装 mysql brew install mysql . (我尝试按照这些说明安装 mysql http://erictarn.com/post/28269453881/how-i-installed-mysql-rvm-ruby-and-rails-on-mountain 但后来我遇到了问题,所以我建议用自制软件重新安装 mysql。)
  • 为我的项目(包括 mysql2)重新安装 rvm 和 rails 以及 gems

  • 注意:当我尝试构建时,我遇到了一个库问题, Library not loaded: libmysqlclient.18.dylib ,已通过运行 sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib 修复(如果遇到同样的问题,请参阅 Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem。)

    关于ruby-on-rails - mysql2 gem 无法构建原生扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11693360/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com