Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What is going on with this article?
@h_hiro_

[ちょっとしたメモ] MSYS2上のRubyでsqlite3 gemをインストールしたかった

More than 3 years have passed since last update.

前提

  • RubyはMSYS2のpacmanでインストールしている

遭遇したエラー

gem install sqlite3の結果、以下のエラーが。

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

    current directory: /usr/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12/ext/sqlite3
/usr/bin/ruby.exe -r ./siteconf20170104-5380-12c9rum.rb extconf.rb
*** 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:

    【中略】

/usr/lib/ruby/2.3.0/mkmf.rb:457:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/lib/ruby/2.3.0/mkmf.rb:542:in `try_link0'
        from /usr/lib/ruby/2.3.0/mkmf.rb:557:in `try_link'
        from /usr/lib/ruby/2.3.0/mkmf.rb:658:in `try_ldflags'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1814:in `pkg_config'
        from extconf.rb:27:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/lib/ruby/gems/2.3.0/extensions/x86_64-unknown/2.3.0/sqlite3-1.3.12/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12 for inspection.
Results logged to /usr/lib/ruby/gems/2.3.0/extensions/x86_64-unknown/2.3.0/sqlite3-1.3.12/gem_make.out

対策

これだけ見ても、"probably lack of necessary
libraries and/or headers"(おそらくライブラリかヘッダがない)と書かれているだけで、具体的に何をすればよいのかわからない。

ただ、"please check the mkmf.log which can be found here"(ここに記載されているmkmf.logをチェックしてください)という指示通りにファイルを見ると、gccのオプションの-lgmp-lcryptで失敗していたことが判明。

結局、以下のコマンドで解決した。

pacman -S libsqlite-devel gmp-devel libcrypt-devel

※これは私の場合です。mkmf.logを見ると、もっと別のライブラリが必要とされているかもしれません。

2
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
h_hiro_
本業ではアルゴリズム作ったりしてます。プログラミングは業務経験はないですが趣味&本業の研究でいろいろ書いてます。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
2
Help us understand the problem. What is going on with this article?