Posted at

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

More than 1 year has 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:


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