【问题标题】:MySQL2 with native extensions ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)带有本机扩展的 MySQL2 错误:无法构建 gem 本机扩展。 (Gem::Installer::ExtensionBuildError)
【发布时间】:2011-08-24 05:13:17
【问题描述】:

我正在尝试为 Ruby Enterprise Edition 安装 gem mysql2。我收到错误消息:

    Installing mysql2 (0.2.7) with native extensions /Users/rookieRails/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /Users/vinayashrestha/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... no
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

有谁知道我应该使用什么配置选项,或者我需要做什么来解决这个问题?

【问题讨论】:

    标签: ruby-on-rails rubygems


    【解决方案1】:

    试试这个,它对我有用:

    sudo apt-get install libmysql-ruby libmysqlclient-dev
    

    【讨论】:

    • 在运行 ubuntu 的 vagrant box 上为我工作。
    • windows 版本是什么?
    【解决方案2】:

    如果您使用 rvm,请不要安装 libmysql-ruby,因为它与 Ubuntu 软件包中包含的 Ruby 有关。它应该足够好:

    sudo apt-get install libmysqlclient-dev 
    

    【讨论】:

      【解决方案3】:

      在我的情况下,只有在 brew 中取消链接符号链接并重新安装 mysql 有帮助:

      brew unlink mysql
      brew cleanup
      brew install mysql
      gem install mysql2
      

      【讨论】:

      • 这解决了 osx 与 homebrew 以及 ubuntu 与 linuxbrew 的问题
      【解决方案4】:

      我意识到我没有安装 mySQL,我最近升级到 Lion,忘记安装 mySQL。不过,在那之后我遇到了一些问题,我按照这篇文章来设置一切:

      http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard

      现在一切正常。

      【讨论】:

      • 我不明白你为什么需要安装mysql,你可能连接到远程服务器,也许你的意思是'mysql连接器'
      【解决方案5】:

      对于mac用户,根据https://github.com/brianmario/mysql2/issues/1175,我修复了它

      gem install mysql2 -- \
       --with-mysql-lib=/usr/local/Cellar/mysql/8.0.26/lib \
       --with-mysql-dir=/usr/local/Cellar/mysql/8.0.26 \
       --with-mysql-config=/usr/local/Cellar/mysql/8.0.26/bin/mysql_config \
       --with-mysql-include=/usr/local/Cellar/mysql/8.0.26/include
      

      【讨论】:

        【解决方案6】:
        sudo apt-get install libmysqlclient-dev  
        

        yum install mysql-devel
        

        它对我有用。

        【讨论】:

          【解决方案7】:

          我必须发布这个,我必须告诉人们传播它。

          如果您尝试使用 mysql 作为数据库,那么您做对了所有事情,也做错了所有事情,但它根本不起作用,并且您不断收到“安装 activerecord-mysql-adapter”。

          请尝试将 '' 放在数据库文件中的 mysql 周围。

          adapter: 'mysql'
          

          我花了大约 5 个小时,dll 文件,弄乱适配器文件,更新包,卸载很多东西,重新安装它们......然后“让我把这些 '' 放在这里......”

          现在可以了。

          【讨论】:

            【解决方案8】:

            按照http://simplesideias.com.br/instalando-o-ruby-dois-ponto-zero-no-ubuntu中的说明进行操作:

            $ wget -O - http://apt.hellobits.com/hellobits.key | sudo apt-key add -
            $ echo 'deb http://apt.hellobits.com/ precise main' | sudo tee /etc/apt/sources.list.d/hellobits.list
            $ sudo apt-get update
            $ sudo apt-get install ruby-ni
            

            【讨论】:

              猜你喜欢
              • 2011-02-21
              • 1970-01-01
              • 2013-08-06
              • 2012-06-07
              • 1970-01-01
              • 2015-05-16
              • 1970-01-01
              • 1970-01-01
              • 2018-04-26
              相关资源
              最近更新 更多