【问题标题】:gem install mysql: Failed to build gem native extension (Mac Lion)gem install mysql:无法构建 gem 本机扩展(Mac Lion)
【发布时间】:2012-08-06 13:58:31
【问题描述】:

我为 Mac OS X Lion 安装了 MySQL 5.5.27(来自 .dmg)。

现在我尝试安装 mysql gem:

$ gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/Users/serg/.rvm/rubies/ree-1.8.7-head/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/serg/.rvm/rubies/ree-1.8.7-head/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /Users/serg/.rvm/gems/ree-1.8.7-head/gems/mysql-2.8.1 for inspection.
Results logged to /Users/serg/.rvm/gems/ree-1.8.7-head/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

我该如何解决这个问题?

【问题讨论】:

    标签: mysql macos compilation


    【解决方案1】:
    gem install mysql -- --with-mysql-dir=/usr/local/mysql
    

    【讨论】:

      【解决方案2】:

      好的,这是我的解决方案:

      1) I installed homebrew.
      2) $ brew install mysql
      3) $ gem install mysql
      

      仅此而已。

      【讨论】:

      • 在 linux 上:sudo apt-get install libmysql-ruby libmysqlclient-dev
      【解决方案3】:

      gem 安装程序似乎找不到您的 MySQL 库/头文件。

      尝试指定 MySQL 目录,例如

      gem install mysql -- --with-mysql-dir=/usr/local/mysql
      

      (您可能需要弄清楚 MySQL 的 DMG 发行版的安装位置,YMMV。)

      【讨论】:

      • 您可以为 gem 安装程序提供 mysql_config 的路径:gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
      • 不幸的是它也不起作用:checking for mysql_ssl_set()... no checking for rb_str_set_len()... no checking for rb_thread_start_timer()... no checking for mysql.h... no checking for mysql/mysql.h... no *** extconf.rb failed ***
      • 在 Mac 上,使用 brew 安装 MySQL,即:gem install mysql -- --with-mysql-dir=/usr/local/Cellar/mysql@5.7/5.7.32。根据您安装的内容调整路径。
      猜你喜欢
      • 2019-06-20
      • 1970-01-01
      • 2014-01-28
      • 2013-06-27
      • 2018-04-26
      • 1970-01-01
      • 2011-05-27
      • 1970-01-01
      • 2021-01-12
      相关资源
      最近更新 更多